diff --git a/Algorithms.lua b/Algorithms.lua index b2f166e..1ab83fc 100644 --- a/Algorithms.lua +++ b/Algorithms.lua @@ -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