Largest sum of digits in all Divisors
##### Submissions: 543   Accuracy: 50.81%   Difficulty: Easy   Marks: 2

Given a integer number n, find largest sum of digits in all divisors of n.

Input:

The first line of the input contains a single integer T, denoting the number of test cases. Then T test case follows, a single line of the input containing a positive integer N.

Output:

For each testcase, print the largest sum of digits of divisors.
Constraints:

1<=T<=100

1<=N<=1000000
Example:

Input:

2

12

68

Output:

6

14

Explanation:

For testcase 1: The divisors are: 1 2 3 4 6 12.  6 is maximum digit-sum among all divisors.

For testcase 2: The divisors are: 1 2 4 68.  68 consists of maximum digit-sum among all divisors.

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Sahil Chhabra
Author: Sahil_Chhabra

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.