Updated for performance

This commit is contained in:
2020-06-16 10:56:04 -04:00
parent d6682ab2cf
commit c108f1a5d6

View File

@@ -37,9 +37,9 @@ public class Problem12 extends Problem{
}
public void solve(){
//Setup the other variables
Boolean foundNumber = false; //TO flag whether the number has been found
Long sum = 1L;
Long counter = 2L; //The next number to be added to the sum to make a triangular number
boolean foundNumber = false; //To flag whether the number has been found
long sum = 1L;
long counter = 2L; //The next number to be added to the sum to make a triangular number
ArrayList<Long> divisors = new ArrayList<Long>();
//Start the timer
@@ -63,11 +63,11 @@ public class Problem12 extends Problem{
timer.stop();
//Save the results
result = String.format("The triangulare number %d is the sum of all numbers >= %d and has %d divisors\n", sum, counter - 1, divisors.size());
result = String.format("The triangular number %d is the sum of all numbers >= %d and has %d divisors\n", sum, counter - 1, divisors.size());
}
}
/* Results:
The triangulare number 76576500 is the sum of all numbers >= 12375 and has 576 divisors
It took 373.274 milliseconds to solve this problem.
It took 305.674 milliseconds to solve this problem.
*/