mirror of
https://bitbucket.org/Mattrixwv/my-classes.git
synced 2026-02-04 03:12:27 -05:00
Updated getNumPrimes() to make algorithm more efficient
This commit is contained in:
@@ -117,6 +117,7 @@ std::vector<T> getPrimes(T goalNumber){
|
|||||||
template<class T>
|
template<class T>
|
||||||
std::vector<T> getNumPrimes(T numberOfPrimes){
|
std::vector<T> getNumPrimes(T numberOfPrimes){
|
||||||
std::vector<T> primes;
|
std::vector<T> primes;
|
||||||
|
primes.reserve(numberOfPrimes); //Saves cycles later
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user