You are given a non-negative integer n. Your task is to find its digital root by repeatedly summing its digits until a single digit remains.
At each step, add all the digits of the current number to obtain a new number. Continue this process until the result is a single digit, then return that digit.
Input: n = 12345
Output: 6
Explanation: The sum of the digits is 1 + 2 + 3 + 4 + 5 = 15. Summing again gives 1 + 5 = 6.
Input: n = 99
Output: 9
Explanation: The first sum is 9 + 9 = 18. Summing again gives 1 + 8 = 9.
Input: n = 0
Output: 0
Explanation: Since 0 is already a single digit, its digital root is 0.
Sign in to write, run, and submit your solution against the full test suite.