LeetCode 258 Add Digits

While grinding problems today, I encountered an interesting one: given a number, repeatedly add the digits until the sum is less than 10. Link.
The problem itself is not hard; recursion or iteration can both solve it. But solving it in O(1) complexity is the real point.

The answer is simple: 1 + (num - 1) % 9.
If you are interested, you can read the proof and extension here: Wikipedia.