CACHE = {}
def fatorial_com_cache(valor):
if valor in CACHE:
return CACHE[valor]
else:
if valor <= 1:
CACHE[valor] = 1
return CACHE[valor]
else:
CACHE[valor] = valor * fatorial_com_cache(valor - 1)
return CACHE[valor]