(n)
| 2 | |
| 3 | |
| 4 | def factorial(n): |
| 5 | if n < 0: # factorial of number less than 0 is not possible |
| 6 | return "Oops!Factorial Not Possible" |
| 7 | elif ( |
| 8 | n == 0 |
| 9 | ): # 0! = 1; when n=0 it returns 1 to the function which is calling it previously. |
| 10 | return 1 |
| 11 | else: |
| 12 | return n * factorial(n - 1) |
| 13 | |
| 14 | |
| 15 | # Recursive function. At every iteration "n" is getting reduced by 1 until the "n" is equal to 0. |
no outgoing calls
no test coverage detected