import functools @functools.cache def fatorial(n): print(f'Calculando fatorial de {n}') if n == 1: return 1 return n * fatorial(n-1) print(fatorial(5)) # Output: Calculando fatorial de 5, 4, 3, 2, 1 print(fatorial(3)) # Output: (usando cache) 6 print(fatorial(5)) # Output: (usando cache) 120