Fixed a couple of typo bugs in the newest functions

This commit is contained in:
2019-01-29 01:30:41 -05:00
parent f79fddf372
commit 86bedfc0cd

View File

@@ -29,6 +29,7 @@
#include <string> #include <string>
//This library is licensed under lgplv3 //This library is licensed under lgplv3
//You can find more information at gmplib.org //You can find more information at gmplib.org
//IN ORDER TO USE THIS LIBRARY AS IS YOU MUST LINK BOTH libgmpxx AND libgmp TO COMPILE
#include <gmpxx.h> //This is necessary for the getGmpFib function for numbers larger than a normal int can hold. It can be commented out if needed #include <gmpxx.h> //This is necessary for the getGmpFib function for numbers larger than a normal int can hold. It can be commented out if needed
namespace mee{ namespace mee{
@@ -121,7 +122,7 @@ std::vector<T> getNumPrimes(T numberOfPrimes){
bool foundFactor = false; bool foundFactor = false;
//If the number is 0 or a negative number return an empty vector //If the number is 0 or a negative number return an empty vector
if(goalNumber < 1){ if(numberOfPrimes < 1){
return primes; return primes;
} }
//Otherwise 2 is the first prime number //Otherwise 2 is the first prime number
@@ -133,7 +134,7 @@ std::vector<T> getNumPrimes(T numberOfPrimes){
//Using possiblePrime >= 3 to make sure it doesn't loop back around in an overflow error and create an infinite loop //Using possiblePrime >= 3 to make sure it doesn't loop back around in an overflow error and create an infinite loop
for(T possiblePrime = 3;(primes.size() < numberOfPrimes) && (possiblePrime >= 3);possiblePrime += 2){ for(T possiblePrime = 3;(primes.size() < numberOfPrimes) && (possiblePrime >= 3);possiblePrime += 2){
//Step through every element in the current primes. If you don't find anything that divides it, it must be a prime itself //Step through every element in the current primes. If you don't find anything that divides it, it must be a prime itself
for(uint64_t cnt = 0;(cnt < primes.size()) && ((primes.at(cnt) * primes.at(cnt)) < goalNumber);++cnt){ for(uint64_t cnt = 0;cnt < primes.size();++cnt){
if((possiblePrime % primes.at(cnt)) == 0){ if((possiblePrime % primes.at(cnt)) == 0){
foundFactor = true; foundFactor = true;
break; break;
@@ -161,7 +162,7 @@ std::vector<T> getFactors(T goalNumber){
std::vector<T> factors; std::vector<T> factors;
//Need to step through each prime and see if it is a factor of the number //Need to step through each prime and see if it is a factor of the number
for(int cnt = 0;cnt < primes.size():){ for(int cnt = 0;cnt < primes.size();){
if((goalNumber % primes[cnt]) == 0){ if((goalNumber % primes[cnt]) == 0){
factors.push_back(primes[cnt]); factors.push_back(primes[cnt]);
goalNumber /= primes[cnt]; goalNumber /= primes[cnt];