weekly_programmer

For Weekly Programming Challenges


Project maintained by AccaliaDeElementia Hosted on GitHub Pages — Theme by mattgraham

Weekly Programmer - Week 2

From Weekly Programmer Challenges

Description

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

What is the sum of the primes less than ten million?

Challenge Description

Your challenge today is to write a program that computes all the primes less than ten million and produce the sum of those primes.

Calculating what numbers are prime is quite tricky, but a sufficiently clever algorithm should be able to produce the answer required for this challenge in ten seconds or less.

Bonus Challenge

1) Finding the primes less than ten million in less than ten seconds is impressive. Can you find the primes less than a hundred million in less than twenty? What about a billion? How far can you go before your algorithm fails to complete the challenge in less than a minute?

2) Finding lists of primes online is easy, can you write a program to consume such a list and produce on demand the sum of all primes under n? (where n is within the range of the list used)

Expected Output

The expected sum is: 3203324994356

Challenge Solutions