Package clothcat.ssta.P001_010

Source Code of clothcat.ssta.P001_010.P10

package clothcat.ssta.P001_010;

import clothcat.ssta.lib.Primes;
import java.util.ArrayList;

/**
* The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
*
* Find the sum of all the primes below two million.
*
*/
public class P10 {

    public static void main(String[] args) {
        System.out.println(new P10().solve());
    }

    private long solve() {
        ArrayList<Long> primes = new Primes(2000000).getPrimeList();
        long sum = 0;
        for (Long l : primes) {
            sum += l;
        }
        return sum;
    }
}
TOP

Related Classes of clothcat.ssta.P001_010.P10

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.