wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> general problem-solving / chatting / whatever >> Fibonacci Series
(Message started by: kens on Jul 24th, 2007, 3:37pm)

Title: Fibonacci Series
Post by kens on Jul 24th, 2007, 3:37pm
What is the most efficient implementation of Fibonacci series?

Title: Re: Fibonacci Series
Post by towr on Jul 24th, 2007, 3:38pm
A closed formula.
Err, that is, if you find the Kth term. If you want to find to print the whole sequence (up to K), then simply remembering the last two and using them to find the next is best.

Title: Re: Fibonacci Series
Post by SMQ on Jul 24th, 2007, 4:28pm

on 07/24/07 at 15:38:50, towr wrote:
A closed formula.

Only if you already know phi to a sufficient precision, otherwise calculating phi takes longer than calculating Fibonacci.  The gmp library, for instance, uses a recursion on Fib(k/2) and Fib (k/2 +/- 1) for calculating large Fibonacci numbers.

--SMQ



Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board