Find all the divisors of the given number :
To find the divisors of , we can iterate from to the square root of . If is a divisor of , then is also a divisor of . We need to consider both and as divisors. If and are the same, we only need to consider one of them. Calculate the sum of digits for each divisor:
For each divisor, we can calculate the sum of its digits by repeatedly extract the last digit by using the remainder of division by , add it to the sum and remove the last digit by dividing the number by . Repeat this process while number greater than .
Don’t forget to keep track of the maximum sum of digits encountered. The time complexity of this approach is O() for each test cases.