1 2 3 4 5 6 7 8 9 10 11 12 13
def factorial(x) if x <= 1 then 1 else x * factorial(x - 1) end end x = [1,2,3,4,5] puts "Result:" puts '[' + x.map {|y| factorial(y) }.join(',') + ']'
1 2
Result: [1,2,6,24,120]