diff --git a/src/main/java/mattrixwv/ProjectEuler/Problems/Problem9.java b/src/main/java/mattrixwv/ProjectEuler/Problems/Problem9.java index 8b1a558..fa4ee3e 100644 --- a/src/main/java/mattrixwv/ProjectEuler/Problems/Problem9.java +++ b/src/main/java/mattrixwv/ProjectEuler/Problems/Problem9.java @@ -29,10 +29,10 @@ public class Problem9 extends Problem{ } public void solve(){ //Setup the variables - Integer a = 1; //Holds the length of the first side - Integer b = 0; //Holds the length of the second side - Double c = 0D; //Holds the length of the hyp - Boolean found = false; //A flag to show whether the solution has been found + int a = 1; //Holds the length of the first side + int b = 0; //Holds the length of the second side + double c = 0D; //Holds the length of the hyp + boolean found = false; //A flag to show whether the solution has been found //Start the timer timer.start(); @@ -62,7 +62,7 @@ public class Problem9 extends Problem{ //Save the results if(found){ - result = String.format("The Pythagorean triplet is %d + %d + %d\nThe numbers' product is %d\n", a, b, c.intValue(), a * b * c.intValue()); + result = String.format("The Pythagorean triplet is %d + %d + %d\nThe numbers' product is %d\n", a, b, Math.round(c), a * b * Math.round(c)); } else{ result = "The number was not found!"; @@ -73,5 +73,5 @@ public class Problem9 extends Problem{ /* Results: The Pythagorean triplet is 200 + 375 + 425 The numbers' product is 31875000 -It took 12.971 milliseconds to solve this problem. +It took 139.599 microseconds to solve this problem. */