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 :
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 :
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