From 86bedfc0cdad039a135ffb451617ab73b76ae561 Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Tue, 29 Jan 2019 01:30:41 -0500 Subject: [PATCH] Fixed a couple of typo bugs in the newest functions --- Algorithms.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Algorithms.hpp b/Algorithms.hpp index 2647e58..8ba2eed 100644 --- a/Algorithms.hpp +++ b/Algorithms.hpp @@ -29,6 +29,7 @@ #include //This library is licensed under lgplv3 //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 //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{ @@ -121,7 +122,7 @@ std::vector getNumPrimes(T numberOfPrimes){ bool foundFactor = false; //If the number is 0 or a negative number return an empty vector - if(goalNumber < 1){ + if(numberOfPrimes < 1){ return primes; } //Otherwise 2 is the first prime number @@ -133,7 +134,7 @@ std::vector getNumPrimes(T numberOfPrimes){ //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){ //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){ foundFactor = true; break; @@ -161,7 +162,7 @@ std::vector getFactors(T goalNumber){ std::vector factors; //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){ factors.push_back(primes[cnt]); goalNumber /= primes[cnt];