Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Find factorial of a number by using recursion using python

  • Python program to find factorial of a number using recursion in python.
  • Algorithm to find factorial of a number using recursion function using python.

#1: Python program to find factorial of a given number using recursion

  1. #Factorial using recursion
  2. def fact(n):
  3.     if n==1:
  4.         return 1
  5.     else:
  6.         return n*fact(n-1)

  7. n=int(input("Enter the number: "))
  8. result=fact(n)
  9. print("Factorial of",n,"is", result)

Output:

  1. Enter the number: 6
  2. Factorial of 6 is 720






This post first appeared on Java Tutorial - InstanceOfJava, please read the originial post: here

Share the post

Find factorial of a number by using recursion using python

×

Subscribe to Java Tutorial - Instanceofjava

Get updates delivered right to your inbox!

Thank you for your subscription

×