Fixed some typos

This commit is contained in:
2020-06-13 16:23:57 -04:00
parent 1e4cb3316e
commit b5be5aa4f1

View File

@@ -37,7 +37,7 @@ public class Algorithms{
ArrayList<Integer> primes = new ArrayList<Integer>(); //Holds the prime numbers ArrayList<Integer> primes = new ArrayList<Integer>(); //Holds the prime numbers
Boolean foundFactor = false; //A flag for whether a factor of the current number has been found Boolean foundFactor = false; //A flag for whether a factor of the current number has been found
//If the numebr is 0 or negative return an empty list //If the number is 0 or negative return an empty list
if(goalNumber <= 1){ if(goalNumber <= 1){
return primes; return primes;
} }
@@ -46,7 +46,7 @@ public class Algorithms{
primes.add(2); primes.add(2);
} }
//We cna now start at 3 and skipp all even numbers, because they cannot be prime //We can now start at 3 and skip all even numbers, because they cannot be prime
for(int possiblePrime = 3;possiblePrime <= goalNumber;possiblePrime += 2){ for(int possiblePrime = 3;possiblePrime <= goalNumber;possiblePrime += 2){
//Check all current primes, up to sqrt(possiblePrime), to see if there is a divisor //Check all current primes, up to sqrt(possiblePrime), to see if there is a divisor
Double topPossibleFactor = Math.ceil(Math.sqrt(possiblePrime)); Double topPossibleFactor = Math.ceil(Math.sqrt(possiblePrime));
@@ -127,7 +127,7 @@ public class Algorithms{
ArrayList<BigInteger> primes = new ArrayList<BigInteger>(); //Holds the prime numbers ArrayList<BigInteger> primes = new ArrayList<BigInteger>(); //Holds the prime numbers
Boolean foundFactor = false; //A flag for whether a factor of the current number has been found Boolean foundFactor = false; //A flag for whether a factor of the current number has been found
//If the numeber is 1, 0 or negative return an empty list //If the number is 1, 0 or negative return an empty list
if(goalNumber.compareTo(BigInteger.valueOf(1)) <= 0){ if(goalNumber.compareTo(BigInteger.valueOf(1)) <= 0){
return primes; return primes;
} }
@@ -136,7 +136,7 @@ public class Algorithms{
primes.add(BigInteger.valueOf(2)); primes.add(BigInteger.valueOf(2));
} }
//We cna now start at 3 and skipp all even numbers, because they cannot be prime //We can now start at 3 and skip all even numbers, because they cannot be prime
for(BigInteger possiblePrime = BigInteger.valueOf(3);possiblePrime.compareTo(goalNumber) <= 0;possiblePrime = possiblePrime.add(BigInteger.valueOf(2))){ for(BigInteger possiblePrime = BigInteger.valueOf(3);possiblePrime.compareTo(goalNumber) <= 0;possiblePrime = possiblePrime.add(BigInteger.valueOf(2))){
//Check all current primes, up to sqrt(possiblePrime), to see if there is a divisor //Check all current primes, up to sqrt(possiblePrime), to see if there is a divisor
BigInteger topPossibleFactor = possiblePrime.sqrt().add(BigInteger.valueOf(1)); BigInteger topPossibleFactor = possiblePrime.sqrt().add(BigInteger.valueOf(1));
@@ -331,8 +331,7 @@ public class Algorithms{
goalNumber /= goalNumber; goalNumber /= goalNumber;
} }
//If for some reason the goalNumber is not 1 throw an error //TODO: If for some reason the goalNumber is not 1 throw an error
///Need to add the appropriate error here
//Return the list of factors //Return the list of factors
return factors; return factors;