HGPA

Recursion

def fibonacci(n):
    if n < 2:
        return n
    else:
        return fibonacci(n-1) + fibonacci(n-2)
def fibonacci(num):
    hashmap = {}

    def f(n):
        if n in hashmap:
            return hashmap[n]
        if n < 2:
            return n
        hashmap[n] = f(n-1) + f(n-2)
        return hashmap[n]

    return f(num)
Filename: recursion.md (Edit)
Modified: 2017-02-25 (2a439f02c6a8a5282b6b2152f312cbf219e25d4c)
Created: 2017-02-25 (2a439f02c6a8a5282b6b2152f312cbf219e25d4c)