题目描述
You are given a natural number. Repeatedly sum its digits until the smallest possible two-digit number remains. Then multiply the digits of the remaining two-digit number and return it.
Example 1:
Input: n = 19
Output: 0
Explanation: 1+9 = 1+0 = 1 and 1 came from 10
thus 10 = 0.
Example 2:
Input: n = 129
Output: 2
Explanation: 1+2+9 = 1+2 = 3 and 3 came from 12
thus 12 = 2.
Your Task:
You don't need to read input or print anything. Complete the function repeatedSumMul() which takes n as the input parameter and returns the product of the digits of the value before the single digit.
Expected Time Complexity: O(logn)
Expected Auxiliary Space: O(1)
Constraints:
1<= N <=2^{32}
输入格式
见题面
输出格式
见题面
样例输入
n = 19
样例输出
0