|
Re: Re: Beginners Digest, Vol 18, Issue 2: msg#00013lang.smalltalk.squeak.beginners
On Oct 3, 2007, at 7:31 AM, Michael Davies wrote: If you're Actually, in the case of the Fibonacci sequence, the best way to speed it up is to use the closed-form formula: nthFibonacci |phi1 phi2 term1 term2| phi1 := (1 + 5 sqrt) / 2. phi2 := (1 - 5 sqrt) / 2. term1 := phi1 raisedTo: self. term2 := phi2 raisedTo: self. ^((term1 - term2) / (5 sqrt)) rounded. Sorry, I realize the OP requested a recursive solution, but I couldn't resist. :)
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: [croquet-dev] Re: Quinto game in SBE, Scott Wallace |
|---|---|
| Next by Date: | Re: Re: Beginners Digest, Vol 18, Issue 2, Bert Freudenberg |
| Previous by Thread: | Re: Re: Beginners Digest, Vol 18, Issue 2, Michael Davies |
| Next by Thread: | Re: Re: Beginners Digest, Vol 18, Issue 2, Bert Freudenberg |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |