Loading...
Loading...
Loading...
The digital root of a number is found by adding its digits, then adding the digits of that sum, and so on until one digit is left. Write digit_sum(n) and a recursive digital_root(n) that uses it, and print the digital root.
Example
Input
38
Output
2
3 + 8 = 11, then 1 + 1 = 2.
Try the problem first. Open one hint at a time.
If n is below 10 it is already the answer.
Otherwise the answer is the digital root of the digit sum.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor