Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
uses crt;
var n,i,s:integer;
begin
clrscr;
write('Nhap n='); readln(n);
s:=0;
i:=1;
while i<=n do
begin
s:=s+i;
inc(i);
end;
writeln(s);
readln;
end.
Var i, n, S: integer;
Begin
Read(n);
S:=0;
If i mod 2 = 0 then while i:=1 to n do S:=S+i;
Write (S);
Readln;
End.
Ko bt đúng ko :)
Var i, n, S: integer;
Begin
Read(n);
S:=0;
If i mod 2 = 1 then while i:=1 to n do S:=S+i;
Write (S);
Readln;
End.
Ko bt đúng ko :)
Câu 1:
program Tinhtong:
var
n, i, sum: integer;
begin
write('Nhap n: ');
readln(n);
sum := 0;
for i := 2 to n do
begin
if i mod 2 = 0 then
begin
sum := sum + i;
end;
end;
writeln('Tong cac so chan tu 2 toi ', n, ' la ', sum);
readln;
end.
Câu 2:
program Tinhtong:
var
n, i, sum: integer;
begin
write('Nhap n: ');
readln(n);
sum := 0;
for i := 1 to n do
begin
if i mod 2 = 1 then
begin
sum := sum + i;
end;
end;
writeln('Tong cac so le tu 1 toi ', n, ' la ', sum);
readln;
end.
uses crt;
var i,n,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do t:=t+i;
writeln(t);
readln;
end.
Câu 6:
uses crt;
var n,i:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
if n mod i=0 then write(i:4);
readln;
end.
5:
uses crt;
var n,i,dem:integer;
begin
clrscr;
readln(n);
dem:=0;
for i:=0 to n do
if i mod 2=1 then
begin
write(i:4);
dem:=dem+1;
end;
writeln;
writeln(dem);
readln;
end.
1:
uses crt;
var n,i,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do
t:=t+i*i;
write(t);
readln;
end.
2
program bt2;
var i,n,t:integer;
begin
readln(n);
s:=0;
for i:=1 to n do
if i mod 2 = 1 then s:=s+i;
readln;
end.
vòng lặp for
program dfds;
uses crt;
var i,n,m:integer;
begin
clrscr;
write('n=');
readln(n);
for i:=1 to n do m=m+i;
write('gia tri cua day so M la ',' ',m);
readln;
end.
var n,i,s:integer;
begin
write('n=');readln(n);
s:=0;
for i:=1 to n do s:=s+i;
write(s);
readln;
end.