Difficulty | Tags | Solution Link |
---|---|---|
Medium | [Integers] | To Do |
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.
38
3 + 8 = 11
1 + 1 = 2
// return 2
5419
5 + 4 + 1 + 9 = 19
1 + 9 = 10
1 + 0 = 1
// return 1
Input | Output |
---|---|
38 | 2 |
5419 | 1 |