Skip to main content

8. Program to calculate the factorial using recursion

#PROGRAM TO CALCULATE THE FACTORIAL USING RECURSION
def factorial(n):
      if n==1:
            return 1
      elif n>1:
            return n*factorial(n-1)
#MAIN
a=int(input('enter the number for the factorial'))
print('Factorial for the number',a,'is :',factorial(a))

Comments