Please enter your email address or userHandle.
Given a integer number n, find largest sum of digits in all divisors of n.
n = 12
The divisors of 6 are: 1,2,3,4,6,12.
6 is the maximum digit-sum among all divisors.
n = 34
The divisors of 34 are: 1,2,17,34.
8 is the maximum digit-sum among all divisors.
You don't need to read input or print anything. Your task is to complete the function getLargest() which takes an Integer n as input and returns the answer.
Expected Time Complexity: O(sqrt(n)*log(n))
Expected Auxiliary Space: O(1)
1 <= n <= 106
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.