I couldn’t figure out the O(1) approach, so here’s the simulation method: Repeatedly sum all the digits until the sum is less than 10.
| |
I couldn’t figure out the O(1) approach, so here’s the simulation method: Repeatedly sum all the digits until the sum is less than 10.
| |