If num = 0, return 0.
Otherwise return 1 + (num - 1) % 9.
This runs in constant time and uses the modular property.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
(O(1) formula)
If num = 0, return 0.
Otherwise return 1 + (num - 1) % 9.
This runs in constant time and uses the modular property.