From e3a3f665dfcc65d483c2435a976507077266bcc2 Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Fri, 22 Mar 2019 20:07:23 -0400 Subject: [PATCH] Fixed bug in getDivisors --- Algorithms.lua | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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