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)
A technology and programming blog to share knowledge and solutions to problems came across
Comments
Post a Comment