Skip to main content

Python : Function example with factorial program


Below program shows the example of python program to print the factorial of a number by defining a function recursively.

#!/usr/bin/python

def factorial(num):
if num == 0:
return 1
return num*factorial(num-1)

print factorial(5)


Comments