diff --git a/Algorithms.lua b/Algorithms.lua index 34cf9f2..298855e 100644 --- a/Algorithms.lua +++ b/Algorithms.lua @@ -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