Java Implementation of Problem 10

View source code here on GitHub!

Includes

Problem Solution

public class p0010 implements IEuler
Object answer()
Returns:

The answer to Project Euler problem 10

 1/*
 2Project Euler Problem 10
 3
 4Problem:
 5
 6The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
 7
 8Find the sum of all the primes below two million.
 9*/
10package euler;
11
12import euler.lib.Primes;
13
14public class p0010 implements IEuler {
15    @Override
16    public Object answer() {
17        return Primes.primesUntil(2000000L)
18                     .filter(i -> i != null)
19                     .reduce(0L, Long::sum);
20    }
21}

Tags: prime-number, java-iterator