You are viewing a single comment's thread. Return to all comments →
import math def divsum(n): result=0 for i in range(2,(int)(math.sqrt(n))+1): if(n%i==0): if(i==n/i): result=result+i else: result=result+(i+n//i) return (result+n+1) number=int(input()) value=0 for i in range(1,number+1): if((divsum(i)/i)-(divsum(i)//i)==float(1/2)): value=value+i print(value)
please help me to optimize my code ,it didn't execute within the time limits for many test cases.
lue) `
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #241: Perfection Quotients
You are viewing a single comment's thread. Return to all comments →
please help me to optimize my code ,it didn't execute within the time limits for many test cases.
lue) `