Var a,b,s1,s2:integer;
function sum(n:integer):integer;
var s:integer;
begin
s:=0;
while n<>0 do
begin
s:=s+n mod 10;
n:=n div 10;
end;
sum:=s;
end;
begin
write('a = ');
readln(a);
s1:=sum(a);
writeln(' s1 = ',s1);
b:=a;
while s1<>s2 do
begin
b:=b+1;
s2:=sum(b);
end;
writeln('b = ',b,' s2 = ',s2);
end.
Пример:
a = 153
s1 = 9
b = 162 s2 = 9