Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def arrayElementsProduct(inputArray)
- x = 0
- array_length = inputArray.length
- if array_length == 1 then
- return inputArray[x]
- end
- if array_length == 2 then
- return inputArray[x] * inputArray[x + 1]
- end
- sum = inputArray[x] * inputArray[x + 1]
- x = 2
- while (x < array_length)
- sum = sum * inputArray[x]
- x = x + 1
- end
- return sum
- end
Advertisement
Add Comment
Please, Sign In to add comment