I promise I won't bitch and groan


nneonneo wrote:Mmm...interesting. He wants a challenge
Here's a first warm-up question:
You may, or may not know of the Fibonacci numbers; it's a sequence of numbers f1, f2, f3, ... with f1=f2=1 and f(n) = f(n-1) + f(n-2); Wikipedia explains it best.
Write a Python function (call it "f") to generate the Fibonacci numbers "the obvious way", i.e. according to the definition. Try calculating f(100), and you will see it takes a very long time (don't bother waiting for it -- it would literally take millenia to finish!)
Now, using a Python dictionary, think about how you might go about making this go much faster (and no cheating by using Binet's formula!)

Return to Interpreted Languages
Users browsing this forum: No registered users and 0 guests