Updated getNumPrimes() to make algorithm more efficient

This commit is contained in:
2019-01-29 01:12:47 -05:00
parent 2fc5f8c425
commit b397d00290

View File

@@ -117,6 +117,7 @@ std::vector<T> getPrimes(T goalNumber){
template<class T>
std::vector<T> getNumPrimes(T numberOfPrimes){
std::vector<T> primes;
primes.reserve(numberOfPrimes); //Saves cycles later
bool foundFactor = false;
//If the number is 0 or a negative number return an empty vector