Factorial using recursion :
Program:
print("program to calculate factorial of a number")
num=int(input("Enter the number"))
def fact(num):
if(num<1):
print("Enter only positive values")
exit()
elif(num==1):
return num
else:
return num*fact(num-1)
print(fact(num))
Output:
program to calculate factorial of a number
Enter the number5
120