• + 0 comments

    Python 3 - Code to Optimizing time

    class Calculator(AdvancedArithmetic):
        def divisorSum(self, n):
            divisors = set()            # Divisors are unique so using set
            for i in range(1,int(n**(1/2))+1):    # Going upto sqrt of n
                if n % i == 0:
                    divisors.add(i)        # Adding divisor to divisors set
                    divisors.add(n/i)    # Adding Quotient to divisors set
            return int(sum(divisors))