mirror of
https://bitbucket.org/Mattrixwv/pyclasses.git
synced 2025-12-06 18:33:58 -05:00
Fixed bug in fix of getDivisors two number bug
This commit is contained in:
@@ -143,14 +143,11 @@ def getDivisors(goalNumber: int) -> list:
|
|||||||
#If the number is 1 return just itself
|
#If the number is 1 return just itself
|
||||||
elif(goalNumber == 1):
|
elif(goalNumber == 1):
|
||||||
divisors.append(1)
|
divisors.append(1)
|
||||||
#Otherwise add 1 and itself to the list
|
return divisors
|
||||||
else:
|
|
||||||
divisors.append(1)
|
|
||||||
divisors.append(goalNumber)
|
|
||||||
|
|
||||||
#Start at 3 and loop through all numbers < (goalNumber / 2 ) looking for a number that divides it evenly
|
#Start at 3 and loop through all numbers < (goalNumber / 2 ) looking for a number that divides it evenly
|
||||||
topPossibleDivisor = math.ceil(math.sqrt(goalNumber))
|
topPossibleDivisor = math.ceil(math.sqrt(goalNumber))
|
||||||
possibleDivisor = 2
|
possibleDivisor = 1
|
||||||
while(possibleDivisor <= topPossibleDivisor):
|
while(possibleDivisor <= topPossibleDivisor):
|
||||||
#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):
|
||||||
|
|||||||
Reference in New Issue
Block a user