A factorial is positive integer n, and denoted by n!. Then the product of all positive integers less than or equal to n.
In this article, we are going to calculate the factorial of a number using recursion.
Input: 5 Output: 120 Input: 6 Output: 720
If fact(5) is called, it will call fact(4), fact(3), fact(2) and fact(1). So it means keeps calling itself by reducing value by one till it reaches 1.
Number : 5 Factorial : 120
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course