From e4b59ed7c3aec3e2c83ec2020efc7178a2de65ef Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Mon, 4 Feb 2019 20:34:11 -0500 Subject: [PATCH] Fixed a but where 2 was not being added to the prime numbers --- Algorithms.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Algorithms.py b/Algorithms.py index b04fcd8..b64bf2e 100644 --- a/Algorithms.py +++ b/Algorithms.py @@ -14,10 +14,10 @@ def getPrimes(goalNumber: int): #If the number is 0 or negative return an empty list if(goalNumber <= 1): return primes - - #If the number is even 2 is a factor and all other factors will be odd - if((goalNumber %2) == 0): + #Otherwise the number is at least 2, therefore 2 should be added to the list + else: primes.append(2) + #We can now start at 3 and skip all even numbers, because they cannot be prime for possiblePrime in range(3, goalNumber + 1, 2): #Need goalNumber + 1 to account for goalNumber being prime #Check all current primes, up to sqrt(possiblePrime), to see if there is a divisor