You are viewing a single comment's thread. Return to all comments →
My Python solution:
if __name__ == '__main__': n = int(input().strip()) nums = [i for i in range(1, n+1) if n%i==0] best = 0 max_sum = 0 for x in nums: soma = sum(map(int,str(x))) if soma > max_sum: best, max_sum = x, soma elif soma == max_sum: best = min(x, best) print(best)
Seems like cookies are disabled on this browser, please enable them to open this website
Best Divisor
You are viewing a single comment's thread. Return to all comments →
My Python solution: