Skip to content
GitHub no longer supports this web browser. Learn more about the browsers we support.
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time. Cannot retrieve contributors at this time
19 lines (17 sloc) 574 Bytes
# problemName = "Summation of primes"
# problemNum = 10
# solutionBy = "FIGBERT"
# language = "Python"
# dateCompleted = "28/01/2020"
def sieveOfEratosthenes(limit):
prime = [True for _ in range(limit+1)]
p = 2
while (p * p <= limit):
if (prime[p] == True):
for i in range(p * 2, limit + 1, p):
prime[i] = False
p += 1
prime[0:2] = [False, False]
return [p for p in range(limit + 1) if prime[p]]
primes = sieveOfEratosthenes(2000000)
print(f"The sum of all the primes below two million is {sum(primes)}")
You can’t perform that action at this time.