# Talk:Calculate the Fibonacci sequence

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This page has been locked from anonymous users temporarily. Please log in to edit this page.

## C#

C# code is a bit slow i tried to find the 46th number and i left it going i went for a walk with the dog came back and it was still going :)

Ouch! We should look in to improving that... I wish I knew C# well. -Nostromo 20:09, 30 September 2006 (CDT)

## Java

The current English Java implementation of generating Fibonacci numbers is horribly slow, probably as slow as the C# method described above (mainly because it is recursive, giving it a very large time complexity). I have written a far more efficient method that can generate the first ~1450 Fibonacci numbers in a fraction of a second, as compared to the VERY long (and tedious) wait that you will be in for if you attempt to generate even just a hundred or so Fibonacci numbers with the recursive method. My algorithm combines the mathematical formula described here at Wikipedia and an iterative method that caches previous values, allowing for very quick generation of many consecutive Fibonacci numbers. It's definitely a lot better than the English recursive, and more convenient for English speakers (which I imagine is a large portion of the userbase) than the ever-so-slightly faster German (?) implementation. I think maybe the slow recursive method should be removed (or, better yet, if anyone cares to decipher the other method, optimized!) Until the English recursive method is sped up, however, I think this will serve as an acceptable substitute. Plus, unlike the German one, mine doesn't throw some crazy exception when you get into the upper stratosphere of numbers (specifically, the other method throws a whole pile of exception starting at the 4921st Fibonacci number (which would be rounded to infinity by Java anyways, but still)). Also, I apologize if the language is not actually German; I'm monolingual and am only guessing! --Why My Fleece? 23:29, 18 April 2007 (CDT)

Alright, I sped up the recursive method significantly, so I've just gone ahead and deleted my alternative since its so much more verbose. --Why My Fleece? 20:42, 4 May 2007 (CDT)