Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
40
Task/Digital-root/Zonnon/digital-root.zonnon
Normal file
40
Task/Digital-root/Zonnon/digital-root.zonnon
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
module Main;
|
||||
type
|
||||
longint = integer{64};
|
||||
|
||||
type {public,ref}
|
||||
Response = object (dr,p: longint)
|
||||
var {public,immutable}
|
||||
digitalRoot,persistence: longint;
|
||||
|
||||
procedure {public} Writeln;
|
||||
begin
|
||||
writeln("digital root: ",digitalRoot:2," persistence: ",persistence:2)
|
||||
end Writeln;
|
||||
|
||||
begin
|
||||
self.digitalRoot := dr;
|
||||
self.persistence := p;
|
||||
end Response;
|
||||
|
||||
procedure DigitalRoot(n:longint):Response;
|
||||
var
|
||||
sum,p: longint;
|
||||
begin
|
||||
p := 0;
|
||||
loop
|
||||
inc(p);sum := 0;
|
||||
while (n > 0) do
|
||||
inc(sum,n mod 10);
|
||||
n := n div 10;
|
||||
end;
|
||||
if sum < 10 then return new Response(sum,p) else n := sum end
|
||||
end
|
||||
end DigitalRoot;
|
||||
|
||||
begin
|
||||
write(627615:22,":> ");DigitalRoot(627615).Writeln;
|
||||
write(39390:22,":> ");DigitalRoot(39390).Writeln;
|
||||
write(588225:22,":> ");DigitalRoot(588225).Writeln;
|
||||
write(max(integer{64}):22,":> ");DigitalRoot(max(integer{64})).Writeln;
|
||||
end Main.
|
||||
Loading…
Add table
Add a link
Reference in a new issue