Re: Compution of Fibonacci

From: Date: Tue, 31 Jul 2001 07:26:16 +0000
Subject: Re: Compution of Fibonacci
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-60326@lists.php.net to get a copy of this message
On Tue, 31 Jul 2001, Stig Venaas wrote: > On Tue, Jul 31, 2001 at 11:59:07AM +0500, Saquib Farooq wrote: > > hi > > > > well first of all you have to remove the colon -- ";" sign from > > the end of your while loop ...... that will solve the problem for the time > > out. > > then there is problem with your code, this code will never get you > > the fibonacci since the variable a,b and c never go abone 0, see. :). > > Just in case anyone is interested... If you want to find the n'th > Fibonacci number and not go through the entires sequence, you can > use the formula: > > F(n) = ( P^n - (-P)^(-n) ) / sqrt(5) where P = (1 + sqrt(5))/2 > > and it's also possible to extend Fibonacci numbers to negative n. > Pretty fascinating (: > > Also, if you have F(n) you can find F(n+1). Let x denote F(n). > > F(n+1) = floor( (x + 1 + sqrt(5x^2)) / 2). > > Stig > > Oh please stop that ... you sound like my maths professor :). lol. -- ,,,,, /'^ ^'\ -((o)-(o))- --oOOO--(_)--OOOo------- Saquib Farooq Malik saquib@isb.sdnpk.org saquibfarooq@yahoo.com Sustainable Develpment Network Program (SDNP) Tel: 2270684 .oooO ( ) Oooo. ---\ (-------( )------ \_) ) / (_/

« previous php.general (#60326) next »