Program HOC24;
var i,n,t: integer;
begin
n:=1; t:=0;
while t<=500 do
begin
t:=t+n;
n:=n+1;
end;
writeln('Tong la: ',t);
write('So N nho nhat de tong lon hon 500 la: ',n);
readln
end.
*Cách khác: Dùng Repeat Until
uses crt;
var n,t:integer;
begin
clrscr;
t:=0;
n:=0;
repeat
n:=n+1;
t:=t+n;
until t>500;
writeln(t);
writeln(n);
readln;
end.