Fixed typos

This commit is contained in:
2020-10-03 12:52:19 -04:00
parent 0bc6e5e044
commit da219ec692
4 changed files with 9 additions and 15 deletions

View File

@@ -470,11 +470,7 @@ public class Problem22 extends Problem{
return String.format("The answer to the question is %d", sum); return String.format("The answer to the question is %d", sum);
} }
//Returns the vector of the names being scored //Returns the vector of the names being scored
public ArrayList<String> getNames(){ public static ArrayList<String> getNames(){
//If the problem hasn't been solved throw an exception
if(!solved){
throw new Unsolved();
}
return names; return names;
} }
//Returns the sum of the names scores //Returns the sum of the names scores
@@ -483,7 +479,7 @@ public class Problem22 extends Problem{
if(!solved){ if(!solved){
throw new Unsolved(); throw new Unsolved();
} }
return Algorithms.getLongSum(prod); return sum;
} }
} }

View File

@@ -59,19 +59,17 @@ public class Problem26 extends Problem{
//Loop through every number from 2-999 and use it for the denominator //Loop through every number from 2-999 and use it for the denominator
for(int denominator = 2;denominator <= TOP_NUM;++denominator){ for(int denominator = 2;denominator <= TOP_NUM;++denominator){
ArrayList<Integer> denomList = new ArrayList<Integer>(); ArrayList<Integer> denomList = new ArrayList<Integer>();
boolean endFound = false; //Holds whether we have found an end to the number (either a cycle or a 0 for remainder) boolean endFound = false; //A flag for when we have found an end to the number (either a cycle or a 0 for remainder)
boolean cycleFound = false; //Holds whether a cycle was detected boolean cycleFound = false; //A flag to indicate a cycle was detected
int numerator = 1; //The numerator that will be divided. Always starts at 1 int numerator = 1; //The numerator that will be divided. Always starts at 1
while(!endFound){ while(!endFound){
//Get the remainder after the division //Get the remainder after the division
int remainder = numerator % denominator; int remainder = numerator % denominator;
//Check if the remainder is 0 //Check if the remainder is 0 and set the flag
//If it is set the flag
if(remainder == 0){ if(remainder == 0){
endFound = true; endFound = true;
} }
//Check if the remainder is in the list //Check if the remainder is in the list and set the appropriate flags
//If it is in the list, set the appropriate flags
else if(Algorithms.isFound(denomList, remainder)){ else if(Algorithms.isFound(denomList, remainder)){
endFound = true; endFound = true;
cycleFound = true; cycleFound = true;

View File

@@ -32,8 +32,8 @@ import java.util.ArrayList;
public class Problem27 extends Problem{ public class Problem27 extends Problem{
//Variables //Variables
//Static varibles //Static varibles
private static int LARGEST_POSSIBLE_A = 999; private static final int LARGEST_POSSIBLE_A = 999;
private static int LARGEST_POSSIBLE_B = 1000; private static final int LARGEST_POSSIBLE_B = 1000;
//Instance variables //Instance variables
private int topA; //The A for the most n's generated private int topA; //The A for the most n's generated
private int topB; //The B for the most n's generated private int topB; //The B for the most n's generated

View File

@@ -1,7 +1,7 @@
//ProjectEulerJava/src/main/java/mattrixwv/ProjectEuler/Problems/Problem67.java //ProjectEulerJava/src/main/java/mattrixwv/ProjectEuler/Problems/Problem67.java
//Matthew Ellison //Matthew Ellison
// Created: 03-26-19 // Created: 03-26-19
//Modified: 07-196-20 //Modified: 07-19-20
//Find the maximum total from top to bottom //Find the maximum total from top to bottom
/* /*
59 59