1

Well I have a little problem. I want to get the sum of all numbers below to 1000000, and who has 4 divisors...

I try, but i have a problem because the GetTheSum(n) function always returns the number "6"...

This is my Code :

http://pastebin.com/bhiDb5fe

0

1 Answer 1

2

The problem seems to be that you return as soon as you find the first number (which is 6).

You have this:

def GetTheSum(n):
    k = 0
    for d in range(1,n):
        if NumberOfDivisors(d) == 4:
            k += d
            return k

But you have probably meant this:

def GetTheSum(n):
    k = 0
    for d in range(1,n):
        if NumberOfDivisors(d) == 4:
            k += d
    return k
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.