mirror of
https://bitbucket.org/Mattrixwv/pyclasses.git
synced 2025-12-06 18:33:58 -05:00
Updated to remove a potential bug in the getDivisors function
This commit is contained in:
@@ -139,7 +139,9 @@ def getDivisors(goalNumber: int) -> list:
|
|||||||
#If you find one add it and the number it creates to the list
|
#If you find one add it and the number it creates to the list
|
||||||
if((goalNumber % possibleDivisor) == 0):
|
if((goalNumber % possibleDivisor) == 0):
|
||||||
divisors.append(possibleDivisor)
|
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
|
#Sort the list before returning for neatness
|
||||||
divisors.sort()
|
divisors.sort()
|
||||||
|
|||||||
Reference in New Issue
Block a user