A memoized function remembers its results between invocations for efficiency.