Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/Digital-root/Python/digital-root-1.py
Normal file
13
Task/Digital-root/Python/digital-root-1.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
def digital_root (n):
|
||||
ap = 0
|
||||
n = abs(int(n))
|
||||
while n >= 10:
|
||||
n = sum(int(digit) for digit in str(n))
|
||||
ap += 1
|
||||
return ap, n
|
||||
|
||||
if __name__ == '__main__':
|
||||
for n in [627615, 39390, 588225, 393900588225, 55]:
|
||||
persistance, root = digital_root(n)
|
||||
print("%12i has additive persistance %2i and digital root %i."
|
||||
% (n, persistance, root))
|
||||
Loading…
Add table
Add a link
Reference in a new issue