I want to solve this but I have no idea how to
I´d appreciate your help
given n take the sum of the digits of n if that value has more than one digit continue until there´s only one
Expected output:
16 -> 1 + 6 = 7
942 -> 9 + 4 + 2 = 15 -> 1 + 5 = 6
I tried this but I don´t know how to repeat it untill there is only one digit
Def sum_digit(n):
list_of_digits = list(map(int,str(n)))
su = []
for x in list_of_digits:
x = sum(list_of_digits)
su = x
print(su)
sum_digit(6784)
Use a recursive function to sum the digits of a number until there's only one digit left.