Var i ,n : integer;
S , T : real;
Begin
write ('n=') ; read (n) ;
S:= 0;
T:= 1;
For i:= 1 to n do
S:= S + i;
T:= T * i;
Writeln (' Tong cua ' ,n,' so dau tien la' , S );
Writeln (' Tich của ' ,n,' so dau tien la' , T );
Readln;
End.
Tính tổng:
program tinhtongnso;
uses crt;
var s,i,n:integer;
begin
clrscr;
writeln('Nhap so n');readln(n);
s:=0;
for i:=1 to n do s:=s+i;
writeln('Tong la:',s);
readln
end.
tính tích:
program tinhtichnso;
uses crt;
var i,n:integer;
s:longint;
begin
clrscr;
writeln('Nhap so n');readln(n);
s:=1;
for i:=1 to n do s:=s*i;
writeln('Tich la:',s);
readln
end.