diff --git a/dynamic_programming/factorial.py b/dynamic_programming/factorial.py index 1c9c927f5af3..c01d4f9e4557 100644 --- a/dynamic_programming/factorial.py +++ b/dynamic_programming/factorial.py @@ -1,4 +1,16 @@ +#Factorial is the product of all positive integers less than or equal to a given positive integer +#and denoted by that integer and an exclamation point. +#For example, factorial seven is written 7!, meaning 1 × 2 × 3 × 4 × 5 × 6 × 7. +#Factorial zero is defined as equal to 1. + # Factorial of a number using memoization +#If n = 0, return 1 +#Otherwise if n is in the memo, return the memo's value for n +#Otherwise, +#Calculate (n - 1)! x n +#Store result in the memo +#Return result + from functools import lru_cache