fork download
  1. fib = ->a, b {Enumerator.new {|y| loop {y << a; a, b = b, a + b}}}
  2. f = ->a, b, c {fib.(a, b).take_while(&c.method(:>=)).find_index(c)}
  3. p (1..5).map {|c| [c, f.(1, 1, c)]}
  4.  
Success #stdin #stdout 0s 28216KB
stdin
Standard input is empty
stdout
[[1, 0], [2, 2], [3, 3], [4, nil], [5, 4]]