Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Can you explain please what this decorator do?
building memo is the same as using lru_cache so...
Oh, I see, thanks.
My bad. Didn't see it was already running on python 3.x. :)
I'd use xrange instead of range for range creates a list full with the numbers in the range you specified before using them while xrange evaluates lazily or something like that, therefore xrange is usually faster. Not a big deal on this kata but a thing to consider on bigger iterations/projects.
http://stackoverflow.com/questions/135041/should-you-always-favor-xrange-over-range
http://vairoj.com/2010/04/replace-python-range-with-xrange-for-speed.html
Note: Apparently this only applies to python 2.x as xrange has been removed from python 3.x and range now acts as xrange.
my easy python 101 code for the non-mathematician...
@gambith The method implemented by Zantyr and me allows for much larger values of n without overflowing.
What about?:
def fibElem(N):
q = (5**(1.0/2) + 1) / 2
temp = 1
for i in range(N - 2):
temp = int(temp * q + 0.5)
return temp
N is Natural number.
Fabulous - I can't understand anything though! XD
Wow, thanks!