I need to find the multiplicative digital root of a number in python using only loops.
something that does the same as the below code but using loops:
print("multiplicative digital root of a number Calculator")
print("-"*50)
num = input("Enter a number: ")
def droot(num):
if len(num) == 1:
return num
else:
sum = 0
for i in num:
sum += int(i)
num = str(sum)
return droot(num)
print("The digital root of ", num, " is: ", droot(num))
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…