Given n
, take the sum of the digits of n
. If that value has more than one digit, continue reducing in this way until a single-digit number is produced. This is only applicable to the natural numbers.
def digital_root(n):
sum = 0
print(n)
lst = list(str(n))
for num in lst:
sum += int(num)
if len(str(sum)) > 1:
digital_root(sum)
else:
return sum