Câu 1:
program tonglt;
uses crt;
var n,i:byte;
tong:int64;
begin
clrscr;
write('Nhap n: '); readln(n);
tong:=0;
for i:=1 to n do
tong:=tong+i*i;
write('Tong la: ',tong);
readln(n);
end. {n chi duoc be hon 20 thoi nha}
Câu 2:
program tinhtong;
uses crt;
var n,i:integer;
tong:real;
begin
clrscr;
write('Nhap n: '); readln(n);
tong:=0;
for i:=1 to n do
tong:=tong+1/i;
write('Tong la: ',tong:2:3);
readln
end.
Câu 3:
program tinhtong;
uses crt;
var i,n:integer;
tong:int64;
begin
clrscr;
write('Nhap n: '); readln(n);
tong:=0;
for i:=1 to n do
tong:=tong+i*(i+1);
write('Tpng la: ',tong);
readln
end.
Câu 4:
program tinhtong;
uses crt;
var n,i:integer;
tong:longint;
begin
clrscr;
write('Nhap n: '); readln(n);
tong:=0;
for i:=1 to n do
tong:=t+i;
writeln('Tong cac so nguyen tu 1-->',n,' la: ',tong);
tong:=0;
for i:=1 to n do
if i mod 3=0 then tong:=tong+i;
write('Tong cac so chia het cho 3 tu 1-->',n,' la: ',tong);
readln
end.