Factorial
Recursive function is a function that partially calls itself. It is often used for combinatorial search and sorting methods. A simple good example that uses recursive program is factorial, which is mathematically denoted as “n!”
1! = 1
2! = 2 x 1 = 2
3! = 3 x 2 x 1 = 6
4! = 4 x 3 x 2 x 1 = 24
5! = 5 x 4 x 3 x 2 x 1 = 120
6! = 6 x 5 x 4 x 3 x 2 x 1 = 720

No comments:
Post a Comment