Problem 010


Project Euler

Summation of primes

Problem 10

The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.

Find the sum of all the primes below two million.


A classic prime sieve. Starts by adding 2 to the sum and eliminate all values which are multiple of 2, then add 3 to the sum and eliminate all values which are multiple of 3, and then 5, 7, 11 … so on up to two million. This brute force approach can speed up by limit the values to check be less than \sqrt{n} , where $latext n$ is the limit (e.g. two million).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s