Project Euler #241: Perfection Quotients

  • + 0 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) `