Recursion: Fibonacci Numbers

  • + 0 comments

    It's weird to me that the Fibonacci sequence is academically used as the "hello world" of recursion because I mean:

    def fibonacci(n):
        if n == 1:
            return(1)
        upper = 1
        lower = 1
        for i in range(2,n):
            upper, lower = lower + upper, upper
        return(upper)