Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def product_except?(d)
- e = []
- startvalue = 0
- endvalue = d.length
- product = d.inject(1){|first,n| first * n}
- result = []
- while startvalue < endvalue
- result.push(product/ d[startvalue])
- startvalue = startvalue + 1
- end
- puts "#{result}"
- end
- product_except?([1,2,3,4,5,6,7,8,9])
Add Comment
Please, Sign In to add comment