Fixed some typos

This commit is contained in:
2020-06-15 14:17:37 -04:00
parent dc510c2bc7
commit 7921241b1b
2 changed files with 12 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
//src/main/java/mattrixwv/Algorithms.java
//Matthew Ellison
// Created: 03-02-19
//Modified: 06-07-20
//Modified: 06-15-20
//This class holds many algorithms that I have found it useful to keep around
//As such all of the functions in here are static and meant to be used as stand alone functions
/*
@@ -173,7 +173,7 @@ public class Algorithms{
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
//If the numebr is 0 or negative return an empty list
//If the number is 0 or negative return an empty list
if(numberOfPrimes <= 1){
return primes;
}
@@ -182,7 +182,7 @@ public class Algorithms{
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;primes.size() < numberOfPrimes;possiblePrime += 2){
//Check all current primes, up to sqrt(possiblePrime), to see if there is a divisor
Double topPossibleFactor = Math.ceil(Math.sqrt(possiblePrime));
@@ -195,7 +195,7 @@ public class Algorithms{
else{
++primesCnt;
}
//Check if the index has gone out of range
//Check if the index has gone out of bounds
if(primesCnt >= primes.size()){
break;
}
@@ -218,7 +218,7 @@ public class Algorithms{
ArrayList<Long> primes = new ArrayList<Long>(); //Holds the prime numbers
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(numberOfPrimes <= 1){
return primes;
}
@@ -227,7 +227,7 @@ public class Algorithms{
primes.add(2L);
}
//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(long possiblePrime = 3L;primes.size() < numberOfPrimes;possiblePrime += 2L){
//Check all current primes, up to sqrt(possiblePrime), to see if there is a divisor
Double topPossibleFactor = Math.ceil(Math.sqrt(possiblePrime));
@@ -240,7 +240,7 @@ public class Algorithms{
else{
++primesCnt;
}
//Check if the index has gone out of range
//Check if the index has gone out of bounds
if(primesCnt >= primes.size()){
break;
}
@@ -263,7 +263,7 @@ public class Algorithms{
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
//If the numebr is 0 or negative return an empty list
//If the number is 0 or negative return an empty list
if(numberOfPrimes.compareTo(BigInteger.valueOf(1)) <= 0){
return primes;
}
@@ -272,7 +272,7 @@ public class Algorithms{
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);numberOfPrimes.compareTo((BigInteger.valueOf(primes.size()))) > 0;possiblePrime = possiblePrime.add(BigInteger.valueOf(2))){
//Check all current primes, up to sqrt(possiblePrime), to see if there is a divisor
BigInteger topPossibleFactor = possiblePrime.sqrt().add(BigInteger.valueOf(1));
@@ -285,7 +285,7 @@ public class Algorithms{
else{
++primesCnt;
}
//Check if the index has gone out of range
//Check if the index has gone out of bounds
if(primesCnt >= primes.size()){
break;
}