|
Re: Re: Beginners Digest, Vol 18, Issue 2: msg#00006lang.smalltalk.squeak.beginners
On Oct 3, 2007, at 16:31 , Michael Davies wrote: I want to apply smalltalk to fibonacci numbers. I Now that is plain silly. If you just iterate, why store in an array? (Also note that you want an Array, not an IntegerArray which are only 32 bits. Fibonaccis get large quickly.) fibIter | a b c | a := 0. b := 1. 1 to: self do: [:i | c := b. b := a. a := b + c]. ^ a I doubt you can do much better in Squeak. 100000 fibIter takes under a second on my machine. Well, printing that large number (more than 20000 digits) takes 7 seconds. - Bert -
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Re: Beginners Digest, Vol 18, Issue 2, Bert Freudenberg |
|---|---|
| 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, Michael Davies |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |