This is essentially factorization of a integer, you find all its factors, and add them together
The code used a simple divide and conquer model, iterative might do better
def minSteps(self, n): if n==1: return 0 f = 1 for i in range(int(n**0.5),0,-1): if n%i ==0: f =i break if f == 1: return n return int(self.minSteps(f) + self.minSteps(n/f))
Good job. Similar to what I did during the contest.