diff --git a/Algorithms.hpp b/Algorithms.hpp index df15030..6d37cd4 100644 --- a/Algorithms.hpp +++ b/Algorithms.hpp @@ -1,7 +1,7 @@ //myClasses/Algorithms.hpp //Matthew Ellison // Created: 11-8-18 -//Modified: 1-29-19 +//Modified: 1-30-19 //This file contains the declarations and implementations to several algoritms that I have found useful /* Copyright (C) 2018 Matthew Ellison @@ -141,7 +141,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();++cnt){ + for(uint64_t cnt = 0;(cnt < primes.size()) && ((primes.at(cnt) * primes.at(cnt)) < possiblePrime);++cnt){ if((possiblePrime % primes.at(cnt)) == 0){ foundFactor = true; break;