Program HOC24;
var n,i: integer;
s: longint;
begin
write('Nhap N: '); readln(n);
s:=2021;
for i:=0 to n do s=s+(2*i+1);
write('S= ',s);
readln
end.
*Cách 2: Dùng While do
uses crt;
var s,i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
s:=2021;
i:=0;
while i<=n do
begin
s:=s+(2*i+1);
i:=i+1;
end;
writeln(s);
readln;
end.