Please enter your email address or userHandle.
Given an integer N, recursively sum digits of N until we get a single digit. The process can be described below
If N < 10
digSum(N) = N
digSum(N) = Sum(digSum(N))
N = 1234
The sum of 1+2+3+4 = 10,
digSum(x) == 10 Hence
ans will be 1+0 = 1
N = 9999
Check it yourself.
You don't need to read input or print anything. Your task is to complete the function repeatedSumOfDigits() which takes an integer N and returns the repeated sum of digits of N.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
1 ≤ N ≤ 1000000
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.