Updated for performance

This commit is contained in:
2020-06-16 01:22:08 -04:00
parent 3b6e5e32ce
commit c3798c6907

View File

@@ -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.
*/