ooh, ooh, ooh, I'll be the lame guy who takes his answer from wikipedia!
require 'matrix'
FIB_MATRIX = Matrix[[1,1],[1,0]]
def fib(n)
(FIB_MATRIX**(n-1))[0,0]
end
100.times {|i| puts fib(i) }
Yay!
Sorry :-)
-- Jamie
On 31 Oct 2008, at 14:01, Debbie Carne wrote:
>
> You wouldn't want to generate 100,000 interations my way - unless you
> want to warm the room up a bit ;)
>
> On Fri, Oct 31, 2008 at 1:11 PM, Fred Phillips
> <[EMAIL PROTECTED]> wrote:
>> On Fri Oct 31 12:48:52 2008, Paul Robinson wrote:
>>>
>>> So the deadline has passed. Has anybody got any code they wish to
>>> share?
>>
>> Here's my mathsy solution, takes 0.224 seconds to calculate the
>> 100,000th number in the sequence. It doesn't need to calculate the
>> previous numbers in the sequence to get the next or to test if a
>> number is in it.
>>
>>
>> --
>> Fred O. Phillips
>> http://fophillips.org
>> BBC7 7572 755F 83E0 3209 504A E4F7 874F 1545 9D41
>>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"NWRUG" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/nwrug-members?hl=en
-~----------~----~----~----~------~----~------~--~---