Jump to content

I really need help with this one, I wrote this script but it returns wrong answer.

ans = 0
def sumOf(l):
    x = 0
    for i in l:
        x += i
    return (x)
def d(x):
    y = []
    for i in range(x-1):
        if x % (i+1) == 0:
            y.append(i+1)
    return(sumOf(y))

index=0
while(index<10000):
    index+=1
    a = d(index)
    if index == d(a):
        ans += a+index
print(ans)

 

Link to comment
https://linustechtips.com/topic/1276930-euler-21/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×