Please enter your email address or userHandle.
Gievn two numbers A and B, the task is to find f(AB). f(n) which takes a positive integer n as input and does the following:
if n < 10
else return f( sum_of_digits(n) )
Input: A = 6, B = 6
f(66) = f(46656) = f(27) = f(9) = 9
Input: A = 7, B = 3
f(73) = f(343) = f(10) = f(1) = 1
You don't need to read or print anything. Your task is to complete the function SumofDigits() which takes A and B as input parameter and returns f(AB).
Expected Time Complexity: O(Log(B))
Expected Space Complexity: O(1)
1 <= A, B <= 109
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Login to access your submissions.
Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.