code: def recurrence_memo(initial):
      """
      Memo decorator for sequences defined by recurrence
  
      Examples
      ========
  
      >>> from sympy.utilities.memoization import recurrence_memo
      >>> @recurrence_memo([1]) # 0! = 1
      ... def factorial(n, prev):
      ...     return n * prev[-1]
      >>> factorial(4)
      24
      >>> factorial(3) # use cache values
      6
  
      """
      cache = initial
  
      def decorator(f):
          @wraps(f)
          def g(n):
              L = len(cache)
              if n < L:
                  return cache[n]
              for i in range(L, n + 1):
                  cache.append(f(i, cache))
              return cache[-1]
  
          return g
  
      return decorator
  
label_desc: Use image node_id 1 for calling a global function with example usage: recurrence_memo(initial) and returns: decorator, g, cache, cache