From e4c47129b9f81979965625f787d5635b55b7c220 Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Thu, 31 Jan 2019 12:20:57 -0500 Subject: [PATCH] Updated to remove a potential bug in the getDivisors function --- Algorithms.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Algorithms.py b/Algorithms.py index c63be09..b04fcd8 100644 --- a/Algorithms.py +++ b/Algorithms.py @@ -139,7 +139,9 @@ def getDivisors(goalNumber: int) -> list: #If you find one add it and the number it creates to the list if((goalNumber % possibleDivisor) == 0): divisors.append(possibleDivisor) - divisors.append(goalNumber / possibleDivisor) + #Account for the possibility sqrt(goalNumber) being a divisor + if(possibleDivisor != topPossibleDivisor): + divisors.append(goalNumber / possibleDivisor) #Sort the list before returning for neatness divisors.sort()