Fibonacci in Ruby

So finally we get to Ruby. Is it a ghetto? I don’t know about that, but I do know that writing our simple Fibonacci program in Ruby was a piece of cake. Before we get to the good stuff, though, I’d like to recap where we are, and what we’ve done so far. Here’s a list of the Fibonacci project programs so far:

So this is our sixth version of the simple sequence generator, this time in Ruby

The next installment will be another popular language. Stay tuned to see Fibonacci in Java.

2 Responses to “Fibonacci in Ruby”

  1. blaze Says:

    I like this theme you are using… what is it?

  2. Wilkie Says:

    def f n;a=0;b=q=1;while(q*=2)<n;a,b=a*a+b*b,b*(b+2*a);end;(n-q/2).times{a,b=b,a+b};b;end

    88 characters
    O(log n)