From bc74c0e8c8f062f9d33a5d5f104e855e525089cb Mon Sep 17 00:00:00 2001 From: Si Lam Date: Sun, 2 Oct 2022 12:14:47 -0500 Subject: [PATCH] Enter Factorial logic --- dynamic_programming/factorial.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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