The task Project Euler #10 is: The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million.
I'm confused by why is my code giving me a wrong answer of 1000000000001
.
Here it is:
def prime(a):
for i in range(2,a):
if a % i == 0:
return False
break
return True
sum = 2
for n in range(3,2000000,2):
if prime(n):
sum += n
print(sum)
Could someone explain me what is exactly wrong with it?