Ruby Linear Fibonacci example


SUBMITTED BY: Guest

DATE: May 22, 2015, 6:24 a.m.

FORMAT: Ruby

SIZE: 93 Bytes

HITS: 804

  1. def fib(n)
  2. a, b = 0, 1
  3. n.times { a, b = b + a, a }
  4. a
  5. end
  6. puts fib 30

comments powered by Disqus