uses crt;
var n,i,d,t,x,y:integer;
st:string;
begin
clrscr;
write('nhap n='); readln(n);
str(n,st);
d:=length(st);
t:=0;
for i:=1 to d do
begin
val(st[i],x,y);
t:=t+x;
end;
writeln('tong cac chu so cua ',n,' la:',t);
readln;
end.
Lời giải :
var i,n,s : longint ;
begin
s:=0;
for i:= 1 to 10000000 do
s:=s+i ;
write(s);
readln
end.