You are viewing a single comment's thread. Return to all comments →
class Fib: def __init__(self): self.memo = {0: 0, 1: 1} def fibonacci(self, n): if not n in self.memo: self.memo[n] = self.fibonacci(n-1) + self.fibonacci(n-2) return self.memo[n] n = int(raw_input()) print(Fib().fibonacci(n))
Seems like cookies are disabled on this browser, please enable them to open this website
Recursion: Fibonacci Numbers
You are viewing a single comment's thread. Return to all comments →