No products in the cart.

Write a program to Recursively find …

CBSE, JEE, NEET, CUET

CBSE, JEE, NEET, CUET

Question Bank, Mock Tests, Exam Papers

NCERT Solutions, Sample Papers, Notes, Videos

Write a program to Recursively find the factorial of a natural number.
  • 1 answers

Gaurav Seth 4 years, 4 months ago

def recur_factorial(n):  

   if n == 1:  

       return n  

   else:  

       return n*recur_factorial(n-1)  

# take input from the user  

num = int(input("Enter a number: "))  

# check is the number is negative  

if num < 0:  

   print("Sorry, factorial does not exist for negative numbers")  

elif num == 0:  

   print("The factorial of 0 is 1")  

else:  

   print("The factorial of",num,"is",recur_factorial(num))  

http://mycbseguide.com/examin8/

Related Questions

What are called tokens
  • 2 answers
What is mean by buffering in file handling?
  • 1 answers

myCBSEguide App

myCBSEguide

Trusted by 1 Crore+ Students

Test Generator

Test Generator

Create papers online. It's FREE.

CUET Mock Tests

CUET Mock Tests

75,000+ questions to practice only on myCBSEguide app

Download myCBSEguide App