Skip to content

Instantly share code, notes, and snippets.

@pirj
Forked from NILID/fibonacci.rb
Created September 5, 2012 21:25

Revisions

  1. Phil Pirozhkov revised this gist Sep 5, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fibonacci.rb
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    def fib(n)a,b,s=0,1,[];n.times{s<<a;a,b=b,a+b};s end
    def fib(n)a,b,s=0,1,[];n.times{s<<a;c=b;b=a+b;a=c};s end
    p fib(33)
    [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, ...]
  2. @NILID NILID revised this gist Sep 5, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fibonacci.rb
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    def fib(n)a,b,s=0,1,[];n.times{|t|s<<a;a,b=b,a+b};s end
    def fib(n)a,b,s=0,1,[];n.times{s<<a;a,b=b,a+b};s end
    p fib(33)
    [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, ...]
  3. @NILID NILID revised this gist Sep 5, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fibonacci.rb
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    def fib(n) a,b,s=0,1,[];n.times{|t|s<<a;a,b=b,a+b};s end
    def fib(n)a,b,s=0,1,[];n.times{|t|s<<a;a,b=b,a+b};s end
    p fib(33)
    [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, ...]
  4. @NILID NILID revised this gist Sep 5, 2012. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions fibonacci.rb
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,4 @@
    def fib(n)
    a,b,s=0,1,[];n.times{|t|s<<a;a,b=b,a+b};s
    end
    def fib(n) a,b,s=0,1,[];n.times{|t|s<<a;a,b=b,a+b};s end
    p fib(33)
    [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, ...]
  5. @NILID NILID created this gist Sep 5, 2012.
    6 changes: 6 additions & 0 deletions fibonacci.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    def fib(n)
    a,b,s=0,1,[];n.times{|t|s<<a;a,b=b,a+b};s
    end
    p fib(33)
    [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, ...]