Skip to content

Commit bc74c0e

Browse files
committed
Enter Factorial logic
1 parent 8b8fba3 commit bc74c0e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

dynamic_programming/factorial.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1+
#Factorial is the product of all positive integers less than or equal to a given positive integer
2+
#and denoted by that integer and an exclamation point.
3+
#For example, factorial seven is written 7!, meaning 1 × 2 × 3 × 4 × 5 × 6 × 7.
4+
#Factorial zero is defined as equal to 1.
5+
16
# Factorial of a number using memoization
7+
#If n = 0, return 1
8+
#Otherwise if n is in the memo, return the memo's value for n
9+
#Otherwise,
10+
#Calculate (n - 1)! x n
11+
#Store result in the memo
12+
#Return result
13+
214

315
from functools import lru_cache
416

0 commit comments

Comments
 (0)