mirror of
https://bitbucket.org/Mattrixwv/projecteulerjava.git
synced 2025-12-06 17:13:58 -05:00
Updated for performance
This commit is contained in:
@@ -28,7 +28,7 @@ import mattrixwv.Algorithms;
|
||||
|
||||
public class Problem10 extends Problem{
|
||||
//The largest number to check for primes
|
||||
private static final Long GOAL_NUMBER = 2000000L;
|
||||
private static final long GOAL_NUMBER = 2000000L;
|
||||
|
||||
public Problem10(){
|
||||
super("Find the sum of all the primes below two million");
|
||||
@@ -38,7 +38,7 @@ public class Problem10 extends Problem{
|
||||
timer.start();
|
||||
|
||||
//Get the sum of all prime numbers < GOAL_NUMBER
|
||||
Long sum = Algorithms.getLongSum(Algorithms.getPrimes(GOAL_NUMBER - 1L)); //Subtract 1 from the number so that it is < the number
|
||||
long sum = Algorithms.getLongSum(Algorithms.getPrimes(GOAL_NUMBER - 1L)); //Subtract 1 from the number so that it is < the number
|
||||
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
@@ -50,5 +50,5 @@ public class Problem10 extends Problem{
|
||||
|
||||
/* Results:
|
||||
The sum of all the primes < 2000000 is 142913828922
|
||||
It took 201.347 milliseconds to solve this problem.
|
||||
It took 159.610 milliseconds to solve this problem.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user