题目描述
Given a integer number n, find largest sum of digits in all divisors of n.
Example 1:
Input:
n = 12
Output:
6
Explanation:
The divisors of 6 are: 1,2,3,4,6,12.
6 is the maximum digit-sum among all divisors.
Example 2:
Input:
n = 34
Output:
8
Explanation:
The divisors of 34 are: 1,2,17,34.
8 is the maximum digit-sum among all divisors.
Your Task:
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)
Constraints:
1 <= n <= 10^{6}
输入格式
见题面
输出格式
见题面
样例输入
n = 12
样例输出
6