In this kata, you must create a digital root function.
A digital root is the recursive sum of all the digits in a number. Given n, take the sum of the digits of n. If that value has two digits, continue reducing in this way until a single-digit number is produced. This is only applicable to the natural numbers.
Мой код:
def digital_root(n=1238142342342): while n > 10: b = 0 c = str(n) for i in range(len(c)): a = n % 10 b += a n = n//10 n = b print(n) digital_root()
Test Results:
None should equal 7
None should equal 6
None should equal 2
None should equal 9
None should equal 9
None should equal 0
Что он от меня хочет???