From c108f1a5d64d41e54683486b00a957df582328a6 Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Tue, 16 Jun 2020 10:56:04 -0400 Subject: [PATCH] Updated for performance --- .../mattrixwv/ProjectEuler/Problems/Problem12.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/mattrixwv/ProjectEuler/Problems/Problem12.java b/src/main/java/mattrixwv/ProjectEuler/Problems/Problem12.java index 8a48c7d..45bed2c 100644 --- a/src/main/java/mattrixwv/ProjectEuler/Problems/Problem12.java +++ b/src/main/java/mattrixwv/ProjectEuler/Problems/Problem12.java @@ -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 divisors = new ArrayList(); //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. */