Memoize math - space is cheaper than time.