Fixed but where getProd would return 1

when the ary was empty
This commit is contained in:
2019-03-28 12:13:18 -04:00
parent a8d62c462c
commit c6bcb79fea

View File

@@ -233,6 +233,9 @@ function getSum(ary)
end
function getProd(ary)
if((ary == nil) or (#ary == 0)) then
return 0;
end
local prod = 1; --Holds the product of all elements. Start at 1 because num*1 = num
--Look through every element in the array and add the number to the running product
for location = 1, #ary do