Recursive Fun Python
Recursive Fun Python
# This program will illustrate how Recursive function call with argument
# We have defined fact() function with one argument.
# we gave call to fact() with user input
# This will calculate the factorial of given number using recursive function
# Output has been attached with it.
def fact(num):
if num == 0 :
result = 1
else :
result = num * fact (num - 1)
return result
print("\n\tEnter value for factorial == ",end="")
n1 = eval(input())
print("\n\tFactorial of {} = ".format(n1),fact(n1))
==================================================================
=========================
Output:
F:\Python\Programs>py RecursiveFunPython.py
Factorial of 3 = 6
F:\Python\Programs>py RecursiveFunPython.py
F:\Python\Programs>py RecursiveFunPython.py
Factorial of 5 = 120
F:\Python\Programs>
==================================================================
=========================