function kor(n:integer):integer;
var s:integer;
begin
if n>9 then
s:=0;
while n>0 do
s:=s+n mod 10;
n:=n div 10;
end;
kor:=kor(s);
end
else kor:=n;
writeln(kor(87345691));
writeln(87345691 mod 9);
end.
Результат:
7
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
function kor(n:integer):integer;
var s:integer;
begin
if n>9 then
begin
s:=0;
while n>0 do
begin
s:=s+n mod 10;
n:=n div 10;
end;
kor:=kor(s);
end
else kor:=n;
end;
begin
writeln(kor(87345691));
writeln(87345691 mod 9);
end.
Результат:
7
7