How to calculate factorial of a number using recursion in Python

1 Answer

0 votes
def recursive_factorial(n):
    if n == 0:
        return 1
    else:
        return n * recursive_factorial(n - 1)


n = 5

print("The factorial of", n, "is:", recursive_factorial(n))

'''
run:

The factorial of 5 is: 120

'''

 



answered Feb 20, 2016 by avibootz

Related questions

2 answers 177 views
2 answers 261 views
1 answer 282 views
1 answer 1,002 views
3 answers 339 views
...