
Factorial Calculator
To calculate factorial, enter a number in the “Factorial of” field and press “Calculate.” The result will be shown in the “Result” field.
What is a factorial?
To get the factorial of a number, multiply all whole numbers starting from one up to that number. To write a factorial, use an exclamation mark. For example,
which we can read as “four factorial equals 24” or “the factorial of four is 24.”
Factorials can be used only with non-negative integers (whole numbers equal or greater than 0). For convenience, mathematicians decided that , that is, the factorial of zero equals one.
The factorial formula
The factorial of a given number n can be described using any of the following formulas:
All these formulas give the same result. Formula (a) follows from the definition (multiply all whole numbers starting from one up to n). Formula (b) is a shorter version of formula (a), written using the product operator. Formula (c) is a recursive formula that we can read as “n factorial equals n times the factorial of n minus one.”
Factorial examples
Factorials have many uses. For example, they are popular in combinatorics and probability theory because they tell us in how many ways we can arrange a collection of different objects. Specifically, factorials are used in the formulas for permutations and combinations. They are also used in many other branches of mathematics.
Question: How many ways to order 3 objects?
Let’s say we have three objects: an apple, a banana, and a coconut. We have to decide in what order to eat them. We have three options for what to eat first. Once we have eaten the first fruit, we have two options for what to eat next. When only one fruit is left, we have no further choice – we have to eat whatever is left. Therefore, we can order the fruits in ways:
Question: How many ways to arrange 4 numbers?
Let’s say we have four numbers, ranging from 1 to 4. In how many ways can we arrange them? The answer is . Here are all 24 possibilities:
This only works if we have four different digits. If some of the digits repeat, for example, we have 3, 5, 5, and 7, then we can no longer simply use a factorial – the formula becomes more complicated. This is explained in more detail in the following example.
Question: How many ways to arrange 5 letters?
How many ways are there to arrange letters in the word “FRUIT”? The answer is . There are a lot of possibilities!
This simple formula works only if there are no repeated letters in a word. If you have a word with repeating letters, you need to take the factorial of the word’s length and, for each letter, divide it by the factorial of its repetitions. For example, the word “MISSISSIPPI” has 11 letters, but the letters S and I both appear four times, while P occurs twice. Therefore, the letters in this word can be arranged in 34,650 ways:
Why do we need to put these factorials in the denominator? For example, if two of the four letters S swap places, the word will not change. Because there are four letters S, there are 4! ways to rearrange them. We want to eliminate all these rearrangements because they result in identical words. We do it by dividing the main factorial by 4!.
Question: How many ways to shuffle a deck of 52 cards?
In this final example, we will find out how many ways there are to arrange a deck of 52 cards. This, of course, is the factorial of 52, which is a very large number: 52! = 80,
This means that if you shuffle the cards well, there is practically no chance to encounter the same arrangement twice, ever.
What is the factorial of a number...
Here are some popular factorials:
Question | Answer |
---|---|
What is 0 factorial? | The factorial of 0 is 1. |
What is 1 factorial? | The factorial of 1 is 1. |
What is 2 factorial? | The factorial of 2 is 2. |
What is 3 factorial? | The factorial of 3 is 6. |
What is 4 factorial? | The factorial of 4 is 24. |
What is 5 factorial? | The factorial of 5 is 120. |
What is 6 factorial? | The factorial of 6 is 720. |
What is 7 factorial? | The factorial of 7 is 5,040. |
What is 8 factorial? | The factorial of 8 is 40,320. |
What is 9 factorial? | The factorial of 9 is 362,880. |
What is 10 factorial? | The factorial of 10 is 3,628,800. |
What is 52 factorial? | The factorial of 52 is 80, |
What is 100 factorial? | The factorial of 100 is 93, |
The 100 factorial can be approximated using the scientific notation: .
Factorial in Python
If you are using a programming language like Python, you can use a built-in function:
import math
math.factorial(n)
But if you want to program your own factorial function, you can do it using recursion:
def factorial(n):
if n > 1:
return factorial(n-1) * n
else:
return 1
Or you can use iterations:
def factorial(n):
result = 1
for k in range(2, n + 1):
result *= k
return result
Factorial of a negative number
Factorial is defined only for non-negative integers. There were many attempts to generalize the factorial to work for real and complex numbers. However, the consensus is that the factorial of a negative number should remain undefined. For example, the Gamma function generalizes the factorial to all complex numbers except for... negative integers.
Factorial approximation
Multiplying all integers up to n can be time-consuming, especially when n is large, so mathematicians devised formulas that quickly approximate factorials. Two such famous formulas are listed below.
Stirling’s approximation
Ramanujan’s approximation
How to use the Factorial Calculator?
To use this calculator, enter a number in the field “Factorial of” and press the “Calculate” button. The result will be displayed below. If the result is a large number, it is displayed in two ways: the shorter, approximate result in scientific notation is shown above, and the exact solution is shown below.
The calculator works only with whole numbers, starting from 0. There is no preprogrammed upper limit – if your device and web browser permit, you can enter an arbitrarily large number. On desktop computers, some versions of Chrome can easily calculate the factorial of 10,000,000, whereas Firefox and Safari may struggle to handle numbers higher than 60,000.
For large numbers, it may take several seconds to calculate the result and even longer to display it on your screen. If the number you entered is too large, an error message will be displayed. Sometimes, instead of showing the message, the page crashes and needs to be reloaded.
There is an option to display the result using a base different than 10. You can specify any number between 2 and 36. For example, if you want to get a result in hexadecimal form, enter 16. It is important to remember that the result displayed in scientific notation uses a selected base both in the mantissa and the exponent. The input, on the other hand, is always read and displayed using base 10.
Cite or embed this content
You can use this website free of charge, including for commercial purposes, as long as you cite this website as a source. If you are citing it in a scientific text, you can use the following citation:
To cite this website on the Internet, you can link to it using its main URL (https://minesweeper.us/
You can also embed this page on your website using an iframe element. If you want the page to display only the calculator and hide all the remaining content (menus, article, etc.), you can use the following URL in your src attribute: https://minesweeper.us/factorial-calculator/?iframe=1.
Please credit this page on your website by citing it with a navigable link. You may also want to let us know that you have embedded our app on your website by emailing us at contact@simiade.com. Then, we will be able to inform you if we make any changes to our app that might require webmasters to update how their websites display it.
References
Weisstein, Eric W., Factorial., MathWorld—A Wolfram Resource.
Weisstein, Eric W., Stirling's Approximation, MathWorld—A Wolfram Resource.
Contact us
If you have any questions, comments, or suggestions, you can leave your feedback here:
Or you can contact us by mail:
Adam Narkiewicz
Plac Bankowy 2
00-095 Warszawa
Poland
+48 728235409
contact@simiade.com
https://simiade.com/