For..do
Program HOC24;
uses crt;
var i,n: integer;
S: longint;
begin
clrscr;
write('Nhap N: '); readln(n);
s:=0;
for i:=1 to n do s:=s+i*(i+1);
write('S=',S);
readln
end.
while..do
Program HOC24;
uses crt;
var i,n: integer;
S: longint;
begin
clrscr;
write('Nhap N: '); readln(n);
i:=0; s:=0;
while i<n do
begin
i:=i+1;
s:=s+i*(i+1);
end;
write('S=',S);
readln
end.