I was trying to print the sum of every prime number below two million, it should print 142913828922 but it´s printing 142913827513. How can I get the right number?
This is my code:
def SumOfPrimesBelow(num):
contador = 0
primos = []
for c in range(1, int(math.sqrt(num))):
for c2 in range(1, c):
if c % c2 == 0:
contador += 1
if contador == 1:
primos.append(c)
contador = 0
primos2 = []
for c in range(1, num):
for num5 in primos:
if c != num5:
if c % num5 == 0:
break
if c % num5 == 0:
continue
if c != 1:
primos2.append(c)
cont = 0
for num in primos2:
cont += num
return cont
print(SumOfPrimesBelow(2000000))