Let\'s say I have an array A = [1, 2, 3, 4, 5]
how can I multiply all elements with ruby and get the result? 1*2*3*4*5 = 120
and what if there is an element 0 ?
Well, this is a dummy way but it works :)
A = [1, 2, 3, 4, 5] result = 1 A.each do |i| if i!= 0 result = result*i else result end end puts result