Dynamic Programming21 sections · 916 units
Open in Course

Factorial - Recursive Formula

Breaking it down

The recursive formula is n!=n×(n1)!n! = n \times (n-1)! This says: to compute n!n!, multiply nn by the factorial of n1n-1. For example, 5!=5×4!5! = 5 \times 4!, and 4!=4×3!4! = 4 \times 3!, and so on, until you hit the base case.

Notice how each step reduces the problem size by 11. You're breaking a big problem into a smaller one, trusting that the recursive call will handle it. That trust feels strange at first. "How can I use the answer before I have it?" But you're not. You're defining a relationship between answers. The math guarantees it works.

unnamed (8) (1).jpg