Practice · 4 of 5
Digit Sum Chain
CHALLENGE
Difficulty: intermediate+25 XP
**Description:** Apply the digit-sum operation to n repeatedly (n -> digitSum(n)) until
the result has a single digit. Count how many applications were needed.
**Input:** One line: n (0 <= n <= 10^18).
**Output:** One integer — the number of digit-sum applications to reach one digit.
**Example:** 9875 -> 3 (9875 -> 29 -> 11 -> 2).
Press Submit to check your solution.
Back to lesson: Practice: Number Theory Problem Set