683
In this example we will show you how to work out the factorial of a number in python
The factorial of a non negative number is the product of all the integers from 1 to that number.
For example, the factorial of 6 is 1*2*3*4*5*6 = 720 .
In this example we are using the built in math module factorial function on the number
Example
import math myNumber = int(input(" Please enter any Integer : ")) myFactorial = math.factorial(myNumber) print("The Result of %d = %d" %(myNumber, myFactorial))
When you run this you will see something like this
>>> %Run factorial.py Please enter any Integer : 5 The Result of 5 = 120