No products in the cart.

How to find the factorial of …

CBSE, JEE, NEET, CUET

CBSE, JEE, NEET, CUET

Question Bank, Mock Tests, Exam Papers

NCERT Solutions, Sample Papers, Notes, Videos

How to find the factorial of a number
  • 1 answers

Gaurav Seth 4 years, 8 months ago

The factorial of a number is the product of all the integers from 1 to that number.

For example, the factorial of 6 is <code>1*2*3*4*5*6 = 720</code>. Factorial is not defined for negative numbers, and the factorial of zero is one, <code>0! = 1</code>.

Source Code

<pre> <code># Python program to find the factorial of a number provided by the user. # change the value for a different result num = 7 # To take input from the user #num = int(input("Enter a number: ")) factorial = 1 # check if the number is negative, positive or zero if num < 0: print("Sorry, factorial does not exist for negative numbers") elif num == 0: print("The factorial of 0 is 1") else: for i in range(1,num + 1): factorial = factorial*i print("The factorial of",num,"is",factorial) </code></pre>

 

Output

<pre> <samp>The factorial of 7 is 5040 </samp></pre>
http://mycbseguide.com/examin8/

Related Questions

Define packages
  • 0 answers
Write a program for swapping two numbers?
  • 0 answers
what is palindrone
  • 2 answers
What is alu
  • 1 answers
Write a program for swapping two numbers
  • 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