mirror of
https://bitbucket.org/Mattrixwv/projecteulerjava.git
synced 2025-12-07 01:23:56 -05:00
Updated for performance
This commit is contained in:
@@ -37,9 +37,9 @@ public class Problem12 extends Problem{
|
|||||||
}
|
}
|
||||||
public void solve(){
|
public void solve(){
|
||||||
//Setup the other variables
|
//Setup the other variables
|
||||||
Boolean foundNumber = false; //TO flag whether the number has been found
|
boolean foundNumber = false; //To flag whether the number has been found
|
||||||
Long sum = 1L;
|
long sum = 1L;
|
||||||
Long counter = 2L; //The next number to be added to the sum to make a triangular number
|
long counter = 2L; //The next number to be added to the sum to make a triangular number
|
||||||
ArrayList<Long> divisors = new ArrayList<Long>();
|
ArrayList<Long> divisors = new ArrayList<Long>();
|
||||||
|
|
||||||
//Start the timer
|
//Start the timer
|
||||||
@@ -63,11 +63,11 @@ public class Problem12 extends Problem{
|
|||||||
timer.stop();
|
timer.stop();
|
||||||
|
|
||||||
//Save the results
|
//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:
|
/* Results:
|
||||||
The triangulare number 76576500 is the sum of all numbers >= 12375 and has 576 divisors
|
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.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user