Skip to main content

Checkpoint: digital root

Challenge on lesson: Checkpoint: digital root

CHALLENGE
Difficulty: advanced+25 XP

The **digital root** of a non-negative number: if it has one digit, it is itself; otherwise it is the digital root of the sum of its digits. Implement process(int n) recursively (loop-free helper allowed for digit sum). Examples: 9875 โ†’ 9+8+7+5=29 โ†’ 2+9=11 โ†’ 1+1=2, so 2.

Back to lesson: Checkpoint: digital root