19 August 2026
Digit Root Steps
Medium
Numbers
Keep summing digits until only one is left, and count the rounds.
Given a positive integer n, repeatedly replace it with the sum of its digits until it has only one digit. Return how many rounds of summing that took. Return 0 if n already has one digit.
Constraints
1 <= n <= 10**12
Function signature
def digit_root_steps(n):