From 97e6d1477a1105c8ced0e3f98f8e51c6bf7f01cd Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Fri, 22 Mar 2019 18:25:40 -0400 Subject: [PATCH] Fixed bug in fix of getDivisors two number bug --- Algorithms.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Algorithms.py b/Algorithms.py index cd9313a..67a9d70 100644 --- a/Algorithms.py +++ b/Algorithms.py @@ -143,14 +143,11 @@ def getDivisors(goalNumber: int) -> list: #If the number is 1 return just itself elif(goalNumber == 1): divisors.append(1) - #Otherwise add 1 and itself to the list - else: - divisors.append(1) - divisors.append(goalNumber) + return divisors #Start at 3 and loop through all numbers < (goalNumber / 2 ) looking for a number that divides it evenly topPossibleDivisor = math.ceil(math.sqrt(goalNumber)) - possibleDivisor = 2 + possibleDivisor = 1 while(possibleDivisor <= topPossibleDivisor): #If you find one add it and the number it creates to the list if((goalNumber % possibleDivisor) == 0):