RosettaCodeData/Task/Digital-root/Quackery/digital-root.quackery
2023-07-01 13:44:08 -04:00

23 lines
476 B
Text

[ abs 0 swap
[ base share /mod
rot + swap
dup 0 = until ]
drop ] is digitsum ( n --> n )
[ 0 swap
[ dup base share > while
dip 1+
digitsum again ] ] is digitalroot ( n --> n n )
[ dup digitalroot
rot echo
say " has additive persistance "
swap echo
say " and digital root of "
echo
say ";" cr ] is task ( n --> )
627615 task
39390 task
588225 task
393900588225 task