Python Exercise Example26
# Python2.x Python Exercise Example 26
[ Python 100 Examples](#)
**Question:** Use recursion to find 5!.
**Program Analysis:** Recursive formula: fn=fn_1*4!
Program source code:
## Example
#!/usr/bin/python# -*- coding: UTF-8 -*-def fact(j): sum = 0 if j == 0: sum = 1 else: sum = j * fact(j - 1)return sum print(fact(5))
The output of the above example is:
120
[ Python 100 Examples](#)
YouTip