fib = ->a, b {Enumerator.new {|y| loop {y << a; a, b = b, a + b}}}p fib.(0, 1).take(10)
Standard input is empty
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!