######################################################### # # # Coded by Indranil Ghosh (indranilg49@gmail.com) # # # ######################################################### #Python 2.7.11, OEIS sequence: A287707 #Using memoization process: https://stackoverflow.com/questions/1988804/what-is-memoization-and-how-can-i-use-it-in-python class Memoize: def __init__(self, func): self.func = func self.cache = {} def __call__(self, arg): if arg not in self.cache: self.cache[arg] = self.func(arg) return self.cache[arg] @Memoize def a(n):return n if n==1 or n==3 else 2 if n==2 or n==4 or n==5 else a(a(n - 1)) + a(a(n - a(n - 1)) + a(n - a(n - 2))) print map(a, xrange(1, 101))