Given a non-negative integernum, repeatedly add all its digits untiltheresult has only one digit.
For example:
Given num = 38, theprocess is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, returnit.
Follow up:
Could you doitwithoutany loop/recursion in O(1) runtime?
Show Hint