Adding recursive version using memoization/cache.