Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Digital-root/Smalltalk/digital-root.st
Normal file
17
Task/Digital-root/Smalltalk/digital-root.st
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
digitalRoot :=
|
||||
[:nr :arIn |
|
||||
r := (nr printString asArray collect:#digitValue) sum.
|
||||
r > 9 ifTrue:[
|
||||
digitalRoot value:r value:arIn+1.
|
||||
] ifFalse:[
|
||||
{ arIn+1 . r }
|
||||
].
|
||||
].
|
||||
|
||||
#(
|
||||
627615 39390 588225 393900588225 10 199
|
||||
1999999999999999999999999999999999999999999999999999999999999999999999999999999999999
|
||||
) do:[:nr |
|
||||
Transcript showCR:'%1 has digitalRoot %3 and Additive Resistance %2'
|
||||
withArguments:{nr},(digitalRoot value:nr value:0)
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue