Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
27
Task/Digital-root/MiniScript/digital-root.mini
Normal file
27
Task/Digital-root/MiniScript/digital-root.mini
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
testNumbers = [627615, 39390, 588225, 393900588225, 45, 9991]
|
||||
pad = function(n, width)
|
||||
return (n + " " * width)[:width]
|
||||
end function
|
||||
|
||||
getDigitalRoot = function(n)
|
||||
persistance = 0
|
||||
while floor(log(n)) > 0
|
||||
sum = 0
|
||||
while n > 0
|
||||
sum += n % 10
|
||||
n = floor(n / 10)
|
||||
end while
|
||||
n = sum
|
||||
persistance += 1
|
||||
end while
|
||||
return [n, persistance]
|
||||
end function
|
||||
|
||||
for num in testNumbers
|
||||
digRoot = getDigitalRoot(num)
|
||||
print pad(num, 12), ""
|
||||
print " has a digital root ", ""
|
||||
print digRoot[0], ""
|
||||
print " and additive persistance ",""
|
||||
print digRoot[1]
|
||||
end for
|
||||
Loading…
Add table
Add a link
Reference in a new issue