You are viewing a single comment's thread. Return to all 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))
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Day 19: Interfaces
You are viewing a single comment's thread. Return to all comments →
Python 3 - Code to Optimizing time