I get your question , the problem of computing factorial has a highly repetitive structure. You can use dynamic programming to solve your problem. The conditions for implementing dynamic programming are
 Overlapping subproblems
 optimal substructure
Here is a code which may help you to understand what I am trying to say
 def DPfact(N):

arr={}

if N in arr:

return arr[N]

elif N == 0 or N == 1:

return 1

arr[N] = 1

else:

factorial = N*DPfact(N  1)

arr[N] = factorial

return factorial


num=int(input("Enter the number: "))


print("factorial of ",num," (dynamic): ",end="")

print(DPfact(num))
To get a more clear idea on factorial from basics to such advance level,