• Sign Up
    Time to claim your honor
  • Training
  • Practice
    Complete challenging Kata to earn honor and ranks. Re-train to hone technique
  • Freestyle Sparring
    Take turns remixing and refactoring others code through Kumite
  • Community
  • Leaderboards
    Achieve honor and move up the global leaderboards
  • Chat
    Join our Discord server and chat with your fellow code warriors
  • Discussions
    View our Github Discussions board to discuss general Codewars topics
  • About
  • Docs
    Learn about all of the different aspects of Codewars
  • Blog
    Read the latest news from Codewars and the community
  • Log In
  • Sign Up
Zantyr Avatar
Name:Unknown
Clan:Gdańsk University of Technology
Member Since:Feb 2016
Last Seen:Aug 2024
Profiles:
Following:23
Followers:23
Allies:23
View Profile Badges
  • Stats
  • Kata
  • Collections
  • Kumite
  • Social
  • Discourse
  • Conversations (9)
  • Replies
  • Authored
  • Needs Resolution
  • Custom User Avatar
    • alxndrpi
    • commented on "Find the nth Fibonacci number" kumite
    • 9 years ago

    Can you explain please what this decorator do?

  • Custom User Avatar
    • ofournier
    • commented on "Find the nth Fibonacci number" kumite
    • 9 years ago

    building memo is the same as using lru_cache so...

  • Custom User Avatar
    • gambith
    • commented on "Find the nth Fibonacci number" kumite
    • 9 years ago

    Oh, I see, thanks.

  • Custom User Avatar
    • lgcirilo
    • commented on "Find the nth Fibonacci number" kumite
    • 9 years ago

    My bad. Didn't see it was already running on python 3.x. :)

  • Custom User Avatar
    • lgcirilo
    • commented on "Find the nth Fibonacci number" kumite
    • 9 years ago

    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.

  • Custom User Avatar
    • mkelty
    • commented on "Find the nth Fibonacci number" kumite
    • 9 years ago

    my easy python 101 code for the non-mathematician...

  • Custom User Avatar
    • finsternacht
    • commented on "Find the nth Fibonacci number" kumite
    • 9 years ago

    @gambith The method implemented by Zantyr and me allows for much larger values of n without overflowing.

  • Custom User Avatar
    • gambith
    • commented on "Find the nth Fibonacci number" kumite
    • 9 years ago

    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.

  • Custom User Avatar
    • whaka
    • commented on "Find the nth Fibonacci number" kumite
    • 9 years ago

    Fabulous - I can't understand anything though! XD

  • © 2025 Codewars
  • About
  • API
  • Blog
  • Privacy
  • Terms
  • Code of Conduct
  • Contact

Confirm

  • Cancel
  • Confirm

Collect: undefined

Loading collection data...