Fixed bug in getDivisors

This commit is contained in:
2019-03-22 20:07:23 -04:00
parent 72eae379ed
commit e3a3f665df

View File

@@ -146,15 +146,11 @@ function getDivisors(goalNumber)
--If the number is 1 return just itself
elseif(goalNumber == 1) then
divisors[#divisors+1] = 1;
--Otherwise add 1 and itself to the list
else
divisors[#divisors+1] = 1;
divisors[#divisors+1] = goalNumber;
end
--Start at 3 and loop through all numbers < (goalNumber / 2) looking for a number that divides it evenly
local topPossibleDivisor = math.ceil(math.sqrt(goalNumber));
local possibleDivisor = 2;
local possibleDivisor = 1;
while(possibleDivisor <= topPossibleDivisor) do
--If you find one add it and the number it creates to the list
if((goalNumber % possibleDivisor) == 0) then