Post

Problem 10 - Summation of Primes

Problem 10

This problem asks for the sum of all prime numbers below two million. This is another problem that can be expressed with elegance in SQL. Since we already have the prime numbers up to 2 million stored in our table primes, the solution is as easy as:

1
select sum(number) from primes where number < 2*1000*1000
This post is licensed under CC BY 4.0 by the author.