[Haskell-cafe] Fibbonachi numbers algorithm work TOO slow.

jerzy.karczmarczuk at info.unicaen.fr jerzy.karczmarczuk at info.unicaen.fr
Mon Nov 5 19:53:24 EST 2007

Andrew Bromage: 

> G'day all. 
> (MIS)Quoting Dan Weston:

>> fib00 = 0
>> fib01 = 1
>> fib02 = fib00 + fib01
> [deletia]
>> fib7698760 = fib7698759 + fib7698758
> This is why we don't pay programmers by LOC.
> Incidentally, we've been here before.  Check out this thread: 
>     http://comments.gmane.org/gmane.comp.lang.haskell.cafe/19623

There is one solution missing there (unless I skipped it) 

fib n=((1+s)/2)^n-((1-s)/2)^n)/s where s=sqrt 5 

If some of you complain that this is real, not integer, please remember that
Leonardo of Pisa thought of applying this to rabbits. Well, rabbits are
not integers, they eat carrots and have long ears. They are real thing.
Well, sqrt is Floating.
Now, floating rabbits are less common. 

Jerzy Karczmarczuk 

More information about the Haskell-Cafe mailing list