Factorial Number Code for Python
by inventoYoda in Circuits > Computers
7972 Views, 5 Favorites, 0 Comments
Factorial Number Code for Python
Factorial numbers are clever
Factorial numbers look like this 5!
The exclamation mark means to multiply the number before it with all the numbers after it. For example... 5!=5x4x3x2x1 the answer is 120
With Python I managed to program the function from scratch
Before You Start
This program can come in use in mathematics because most calculator can't calculate bigger numbers because of its computing power.
Before you begin you need to install Python 3.4.3 from the Python website
(But for the attached file you need to use 2.7.3)
The Code
while True:
number1=int(input("Enter number "))
number2=number1+1
multipliers=list()
for i in range(number1,0,-1):
multipliers.append(i)
#print(i)
import operator
import functools
result = functools.reduce(operator.mul,multipliers, 1)
print(result)
Files
Factorial Number.py is the program, so if you don't want to code it yourself then download it, open python and then open the file and run[f5].
100000! is a extremely big factorial number if you want to have a look at what this program can do.
Final Thing
One last thing this program take a long time to calculate large numbers so I wouldn't recommend inputting ridiculously large numbers.
Have Fun!
InventoYoda