Project Euler 10: Calculate the sum of all the primes below two million
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
Sieve the prime numbers less than 2,000,000 and sum them. Having a fast algorithm to sieve primes helps a solution run under a second.
Project Euler 10 SolutionRuns < 0.090 seconds in Python 2.7.
Use this link to get the Project Euler 10 Solution Python 2.7 source.
AnswerSlowly swipe from either end beginning with the white vertical bar to get an idea of the starting or ending digits. For less drama, just double click the answer area. The distance between the two bars will give you an idea of the magnitude. Touch devices can tap and hold the center of the box between the two bars and choose define to reveal the answer.
prime_sieveis listed in Common Functions and Routines for Project Euler
- Prime numbers are used often for solving PE problems and the prime sieve provided here is much faster than traditional methods.