Find the factorial of a number — multiply every whole number from 1 up to n.
Enter a number, then press Calculate.
Factorial Calculator
I had four friends coming for dinner and four chairs around the table, and I wanted to know how many ways I could seat them. So I typed 4 into the Factorial Calculator, and it said 24. Four choices for the first chair, three for the second, two for the third, one for the last, and 4 × 3 × 2 × 1 = 24. That is the whole idea of a factorial in one sentence, and it is the reason I keep the Factorial Calculator open whenever I am counting arrangements.
At a glance: One whole number in, n! out, with the full multiplication shown. The Factorial Calculator takes whole numbers from 0 to 20 only, and it shows the working underneath the answer. A negative number gives the error "Error: factorial is not defined for negative numbers." A number above 20 gives the error "Error: enter a whole number from 0 to 20." Double factorials, subfactorials, multifactorials, primorials and the Gamma function are not in the tool, and this guide works them by hand.
What Is a Factorial?
A factorial is a short way of writing a product of counting numbers. I use the Factorial Calculator whenever I am counting arrangements, because the number of ways to order things grows far faster than most people expect, and the symbol keeps the working short enough to follow.
Factorial Definition in Mathematics
A factorial is the product of every positive whole number from 1 up to n, written as n!. The definition says n! = n × (n − 1) × (n − 2) × ... × 2 × 1. So 3! = 3 × 2 × 1 = 6, and 5! = 5 × 4 × 3 × 2 × 1 = 120. The number n is called the argument, and the result is the factorial of n. The idea is simple, but it is the foundation of permutations, combinations and probability, and you will meet it in every counting problem that matters. A Factorial Calculator does this multiplication for you, and it shows each factor so you can check the working line by line.
Understanding the Exclamation Mark (!) in Factorials
The exclamation mark in 5! is not excitement, and it is not a shout. It is a symbol that means multiply down to 1. The mark was introduced by the French mathematician Christian Kramp in 1808, and it stuck because it is short, clear and impossible to confuse with anything else once you have seen it. I calculate factorial values by reading the mark as an instruction: 7! means start at 7 and multiply by every whole number below it until you reach 1.
Factorial Formula Explained
The factorial formula is written as n! = n(n − 1)(n − 2)...(2)(1), for a whole number n that is 0 or more. The formula also has a recursive form, which says n! = n × (n − 1)!, and that form is the one programmers use, because it turns a long product into a short rule. The formula works the same way for every n, and it is the reason the Factorial Calculator only needs one input: give it n, and it multiplies down to 1 for you. The Factorial article on Wikipedia gives the same definition and the same formula, with the history of the symbol alongside it.
How to Calculate a Factorial Step by Step?
To calculate a factorial, you multiply the number by every whole number below it, down to 1. That is the whole method, and the Factorial Calculator follows it exactly, which is why its steps line reads like your own working.
How to Calculate a Basic Factorial?
Start with the number, then multiply it by the next number down, and keep going until you reach 1. For 4!, that is 4 × 3 = 12, then 12 × 2 = 24, then 24 × 1 = 24, so 4! = 24. I check each step as I go, because one slip in the middle ruins the whole answer, and the Factorial Calculator's steps line does the same check for me.
Factorial Calculation Examples
0! = 1, by definition, and the tool shows it as 0! = 1 = 1. 1! = 1, because the product has only one factor. 2! = 2 × 1 = 2. 3! = 3 × 2 × 1 = 6. 4! = 4 × 3 × 2 × 1 = 24, which is the number of ways to seat my four dinner guests. 5! = 5 × 4 × 3 × 2 × 1 = 120, which is the tool's default example. The Exponent Calculator on CalcSolver shows the power side of that comparison, and it is worth a look if the two keep getting mixed up.
How to Use the Factorial Calculator with Steps?
Type a whole number into the box, press Calculate, and the answer appears with the working underneath. The box starts at 5, so the first thing you see is 5! = 120, with the steps line reading 5 × 4 × 3 × 2 × 1 = 120. A Factorial Calculator with steps is worth more than one that only prints the answer, because the steps line is where you spot a mistake, and seeing the factors is how the method sinks in. The tool takes one number at a time, and it floors a decimal, so 5.9 becomes 5 and gives 5! = 120. If you type a negative number, it answers "Error: factorial is not defined for negative numbers." If you type 21 or more, it answers "Error: enter a whole number from 0 to 20." Both errors are the tool's own words, quoted exactly, and both are worth knowing before you use it for a real problem.
Basic Factorial Values and Special Cases
The first few factorials are the ones you will use most, and they are worth knowing by heart. The values from 0! to 5! cover most homework problems, and they are the ones the Factorial Calculator answers in a single step.
What Is 0! (Zero Factorial)?
Zero factorial is 1. The Factorial Calculator says so itself: type 0 and it answers 0! = 1, with the steps line 0! = 1 = 1. A Factorial Calculator treats 0 as a normal input, not as an error, so 0 is inside its range of 0 to 20, and you can use it in a real calculation without a workaround.
Why Is 0! Equal to 1?
There are three good reasons, and they all give the same answer. First, the empty product: 0! is the product of no numbers at all, and the product of no numbers is defined as 1, just as the sum of no numbers is 0. Second, the division rule: n! = (n + 1)! ÷ (n + 1), so 0! = 1! ÷ 1 = 1 ÷ 1 = 1. Third, combinations: the number of ways to choose 0 things from n things is 1, and the combination formula n! ÷ (0! × n!) only gives 1 when 0! = 1. I check the second reason with the tool, because it is the easiest to verify: it says 5! = 120 and 4! = 24, and 120 ÷ 5 = 24, so the rule holds, and 0! = 1 follows the same rule.
Factorials of 1, 2, 3, 4, and 5
These five values are the ones I keep in my head. 1! = 1, because there is only one number to multiply. 2! = 2 × 1 = 2. 3! = 3 × 2 × 1 = 6, which is the number of ways to order three books on a shelf. 4! = 4 × 3 × 2 × 1 = 24, the dinner-table answer from the introduction. 5! = 5 × 4 × 3 × 2 × 1 = 120, the tool's default example and the number of ways to order five people in a row.
Simple Factorial Patterns
Two patterns make factorials easy to work with. The first is the ratio rule: n! ÷ (n − 1)! = n, so 9! ÷ 8! = 9, and 10! ÷ 9! = 10, which means you can cancel a factorial in a fraction without working out either value. The prime factorisation of 10! shows the pattern clearly: 10! = 2^8 × 3^4 × 5^2 × 7 = 3,628,800, and the two 5s give the two trailing zeros. The rule for counting a prime's exponent in n! is called Legendre's formula, after the French mathematician Adrien-Marie Legendre, and it is the tool students use when a problem asks for the exact prime factors of a factorial.
Different Types of Factorials
The Factorial Calculator does none of these, because it only does the ordinary n!, so everything in this section is worked by hand, and each type gets its own example below.
Double Factorials
A double factorial, written n!!, multiplies every second number down to 1 or 2. For an odd n, it stops at 1: 7!! = 7 × 5 × 3 × 1 = 105, and 9!! = 9 × 7 × 5 × 3 × 1 = 945. For an even n, it stops at 2: 8!! = 8 × 6 × 4 × 2 = 384, and 10!! = 10 × 8 × 6 × 4 × 2 = 3,840. A Factorial Calculator does not do double factorials, so you cannot type 7!! into the box and get 105, and you have to write the product out by hand.
Subfactorials and Derangements
A subfactorial, written !n, counts the derangements of n things, which are the arrangements where nothing is in its original place. The values are !0 = 1, !1 = 0, !2 = 1, !3 = 2, !4 = 9, !5 = 44, and !6 = 265. The classic example is four letters in four envelopes: there are 9 ways to put every letter in the wrong envelope, so !4 = 9. The formula is !n = n! × (1 − 1/1! + 1/2! − 1/3! + ... + (−1)^n/n!), and the signs alternate, which is why the value stays close to n! ÷ e. I calculate factorial values by hand for the subfactorial example, because the Factorial Calculator cannot do it, and the check is simple: !4 = 24 × (1 − 1 + 1/2 − 1/6 + 1/24) = 24 × 0.375 = 9.
Multifactorials
A multifactorial skips more than one number at a time. A triple factorial, written n!!!, steps down by three: 9!!! = 9 × 6 × 3 = 162, and 10!!! = 10 × 7 × 4 × 1 = 280. A quadruple factorial, written n!!!!, steps down by four: 8!!!! = 8 × 4 = 32, and 6!!!! = 6 × 2 = 12. The tool does not do multifactorials either, so these are guide-only, and the working is short enough that you do not need a tool for them.
Primorials
A primorial, written n#, is the product of every prime number up to n. The values are 2# = 2, 3# = 2 × 3 = 6, 5# = 2 × 3 × 5 = 30, 7# = 2 × 3 × 5 × 7 = 210, 11# = 2,310, 13# = 30,030, and 17# = 510,510. Primorials grow fast, because each new prime multiplies the whole product, and 17# is already over half a million.
How Fast Do Factorials Grow?
Factorials grow faster than almost any function you meet in school, and the speed surprises everyone the first time they see it. The jump from 10! to 20! is the best illustration, because 10! is a number you can say in one breath and 20! is a number with nineteen digits. The Factorial Calculator stops at 20 for a reason, and this section shows why that limit exists and what the numbers look like beyond it.
Factorial Growth and Large Numbers
The table below shows how fast the answer grows. 10! = 3,628,800, which is about three and a half million. 20! = 2,432,902,008,176,640,000, which has nineteen digits and is about 2.4 quintillion. Write it in scientific notation and it becomes 2.43 × 10^18, which is a lot easier to read, and the Scientific Notation Calculator on CalcSolver converts it for you. A factorial calculator online shows the same numbers instantly, but the size is what matters, not the speed: 52! is about 8.07 × 10^67, which is the number of ways to shuffle a deck of cards, and it is bigger than the number of atoms in the observable universe. I work out these sizes by hand in the guide, because the tool stops at 20, and the point is the growth, not the exact digits.
Understanding Factorial Patterns
James Stirling found a formula that estimates a factorial without multiplying it out, and it is called Stirling's approximation: n! ≈ √(2πn) × (n/e)^n. The approximation is a guide-only calculation, and I use it when I want a quick sense of size without a calculator, because it is accurate enough for most estimates and it fits in one line. The Factorial Calculator answers exactly for n up to 20, and Stirling's approximation takes over beyond that.

Factorials of Non-Integer Numbers: The Gamma Function
The Gamma function extends the idea to fractions and decimals, and it is the answer to the question of what (1/2)! means. The Factorial Calculator cannot do it, because it only takes whole numbers from 0 to 20, so this whole section is worked by hand, and the values below are the ones worth knowing.
How the Gamma Function Extends Factorials?
The Gamma function, written Γ(x), is defined so that Γ(n) = (n − 1)! for every positive whole number n. That is the bridge: Γ(1) = 0! = 1, Γ(2) = 1! = 1, Γ(3) = 2! = 2, Γ(4) = 3! = 6, and Γ(6) = 5! = 120. The function was introduced by the Swiss mathematician Leonhard Euler, and it extends the factorial to every real number except 0 and the negative whole numbers, where it has poles. A Factorial solver that handles fractions needs the Gamma function underneath, because there is no other honest way to define (1/2)!, and the values below come from that definition.
Calculating Factorials of Fractions and Decimal Values
To work out a fractional factorial, you use the identity (x)! = Γ(x + 1), and you start from the one value that is known exactly, which is Γ(1/2) = √π ≈ 1.7724538509. From that, (1/2)! = Γ(3/2) = (1/2) × √π ≈ 0.8862269255. Then (3/2)! = Γ(5/2) = (3/2) × (1/2) × √π ≈ 1.3293403882, and (5/2)! = Γ(7/2) = (5/2) × (3/2) × (1/2) × √π ≈ 3.3233509704. Two more values worth knowing are (3/4)! = Γ(7/4) ≈ 0.9190625268 and (1/3)! = Γ(4/3) ≈ 0.8929795116. These values do not come from a factorial calculator online, because the Factorial Calculator only takes whole numbers, so I work them from the Gamma identity above, and each one follows from the last by multiplying by the next half-integer.
Real-World Applications of Factorials
Factorials are not an abstract exercise. They count the arrangements in every situation where order matters, and they sit inside the formulas for permutations, combinations and probability. The three sections below cover the places where I actually use the Factorial Calculator, and each one has a concrete number you can check. Factorials are taught in the US Common Core (S-CP), in the UK GCSE, in India's NCERT Class 11 Permutations and Combinations chapter, and in Khan Academy, SAT and ACT preparation.
Factorials in Permutations and Combinations
A permutation is an arrangement where the order matters, and its formula is P(n, r) = n! ÷ (n − r)!. For 10 runners and 3 medals, P(10, 3) = 10 × 9 × 8 = 720, which is the number of ways the medals can be handed out. A combination is a selection where the order does not matter, and its formula is C(n, r) = n! ÷ (r! × (n − r)!). For 10 people and a team of 3, C(10, 3) = 120, which is the number of different teams. The Factorial Calculator works out each factorial in those formulas, so I use the tool for the n! part and do the division by hand, and the answer is always a whole number, which is a good check that the working is right.
Factorials in Probability and Statistics
Probability uses factorials everywhere a counting problem appears. The binomial distribution, which gives the chance of k successes in n trials, is C(n, k) × p^k × (1 − p)^(n − k), and the C(n, k) in that formula is a ratio of factorials. A Factorial solver is the tool I reach for when a probability problem turns into a counting problem, because the factorial is usually the hardest part of the calculation, and once it is done the rest is simple arithmetic. I verify the binomial example against the Factorial Calculator, because the numbers are big enough to slip on: C(10, 3) = 10! ÷ (3! × 7!) = 3,628,800 ÷ (6 × 5,040) = 3,628,800 ÷ 30,240 = 120.
Factorials in Computer Science and Programming
Computer science runs into factorials in two places: counting and complexity. A factorial calculator online is a quick way to see the size of the problem before you write the code, and it is the reason I work out n! first whenever a problem smells exponential. The next section shows how to calculate a factorial in code, with the two methods every programmer learns, and the tool cannot run code, so those examples are guide-only too.
How to Calculate Factorials in Programming Languages?
Every programmer writes a factorial function sooner or later, because it is the standard first example of a loop and of recursion. The two methods below do the same job, and the Factorial Calculator uses the loop method itself, because its own fact function multiplies from 2 up to n.
Factorial Calculation Using Loops
A loop multiplies a running total by each number in turn, which is exactly what the formula says. The same loop in JavaScript looks the same, and it is the method the Factorial Calculator uses, because the tool's own fact function is a loop that starts at 1 and multiplies by 2, then 3, and so on up to n. To calculate factorial values in a loop, you need one variable for the running total and one for the counter, and the loop stops at n, which is why the method works for any whole number.
Factorial Calculation Using Recursion
Recursion defines a factorial in terms of itself: fact(0) = 1, and fact(n) = n × fact(n − 1). The code is three lines, and it reads like the definition, which is why teachers love it. For n = 5, it calls fact(4), which calls fact(3), which calls fact(2), which calls fact(1), which calls fact(0), and then the answers come back up: 1, then 1 × 1 = 1, then 2 × 1 = 2, then 3 × 2 = 6, then 4 × 6 = 24, then 5 × 24 = 120. A solver that runs in a browser has the same limit, and it is the reason the tool caps its input at 20, which is far below any stack problem. The numbers themselves are exact in JavaScript up to 21!, because 21! is divisible by a high power of 2, but the tool's own rule is the 20 limit, not the language's precision, and the error message says so.
Factorial Practice Problems and Examples
The problems below are the ones I use to test whether the method has sunk in. A Factorial Calculator with steps is the best way to check your answers, because the steps line shows the working and you can compare it with your own.
Basic Factorial Problems
Work these out by hand first, then check them against the Factorial Calculator. What is 0!? The answer is 1, by definition. What is 7!? The answer is 5,040, because 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5,040. How many ways can you order 5 books on a shelf? The answer is 5! = 120. How many ways can 4 friends sit in 4 chairs? The answer is 4! = 24, which is the dinner-table problem from the introduction.
Double Factorial Problems
Double factorials are the easiest to practise, because the product is short. What is 7!!? The answer is 105, because 7 × 5 × 3 × 1 = 105. What is 8!!? The answer is 384, because 8 × 6 × 4 × 2 = 384. What is 9!!? The answer is 945, because 9 × 7 × 5 × 3 × 1 = 945. What is 10!!? The answer is 3,840, because 10 × 8 × 6 × 4 × 2 = 3,840. The tool does not do double factorials, so I check these by writing the product out in full, and the working is short enough that it only takes a few seconds.
Factorial Problems with Solutions
These are the longer problems, with the full working shown. Six chairs around a table, six family members: how many seatings? The answer is 6! = 720, because there are six choices for the first chair, five for the second, and so on down to one. A five-card poker hand from a 52-card deck: how many possible hands? The answer is C(52, 5) = 2,598,960, and the working is 52! ÷ (5! × 47!) = 2,598,960. What is (1/2)!? The answer is about 0.8862269255, from the Gamma section, because (1/2)! = Γ(3/2) = (1/2) × √π. The Factorial Calculator checks the first and third of these directly, because 6! and the factorials inside C(52, 5) are all inside its range of 0 to 20, and the other two are guide-only.
Frequently Asked Questions
The seven questions below are the ones I get asked most about factorials, and each one has a short, direct answer.
What does the exclamation mark mean in mathematics?
The exclamation mark in 5! means multiply down to 1. It is an instruction, not excitement, and it was introduced by the French mathematician Christian Kramp in 1808. The mark says start at the number and multiply by every whole number below it until you reach 1, so 5! means 5 × 4 × 3 × 2 × 1 = 120. A Factorial Calculator reads the mark the same way, and its steps line shows the product it stands for, so you can see that the symbol is only a shorthand for a multiplication you could write out in full.
How do you calculate a factorial?
Multiply the number by every whole number below it, down to 1. A Factorial solver is the fastest way to check your answer, because it shows the answer and the working together, and the tool takes one whole number from 0 to 20 and returns n! with the full multiplication underneath.
Why is zero factorial equal to one?
The empty product of no numbers is defined as 1. The division rule n! = (n + 1)! ÷ (n + 1) gives 0! = 1! ÷ 1 = 1. And the combination formula only works when 0! = 1, because choosing 0 things from n things has exactly 1 way. I verify the division rule against the tool, because it is the quickest to check: 7! ÷ 7 = 5,040 ÷ 7 = 720, and 6! = 720, so the rule holds for 6!, and it holds for 0! the same way.
What is the difference between a factorial and a double factorial?
A double factorial multiplies every second number, so 7!! = 7 × 5 × 3 × 1 = 105, and 8!! = 8 × 6 × 4 × 2 = 384. The tool does the ordinary factorial only, so a double factorial has to be worked by hand, and the double factorial section above gives the values for 3!! to 10!!.
Can you calculate the factorial of a decimal or fraction?
The Factorial Calculator cannot, because it only takes whole numbers, and it floors a decimal, so 5.9 becomes 5 and gives 5! = 120. The mathematics can, through the Gamma function, which defines (1/2)! = 0.8862269255, (3/2)! = 1.3293403882, and (5/2)! = 3.3233509704. The values are not whole numbers, and they come from the identity (x)! = Γ(x + 1), with Γ(1/2) = √π ≈ 1.7724538509 as the starting point. A factorial calculator is the wrong tool for a fraction, because its range is whole numbers from 0 to 20, but the Gamma section of this guide works the fractional values by hand, and the answers are listed there.
Why do factorials grow so quickly?
A factorial grows quickly because each step multiplies by a bigger number than the last. Going from 9! to 10! multiplies by 10, but going from 19! to 20! multiplies by 20, so the growth accelerates with every step. The numbers show it: 10! is about 3.6 million, 15! is about 1.3 trillion, and 20! is about 2.4 quintillion, which is a jump of roughly 360,000 times from 10! to 15! and 1.86 million times from 15! to 20!.
What is the largest factorial that can be calculated?
There is no largest factorial in mathematics, because n! is defined for every whole number n, and 100! has 158 digits, 1,000! has 2,568 digits, and the numbers keep growing without an end. The tool stops at 20, because its own rule is whole numbers from 0 to 20, and 20! = 2,432,902,008,176,640,000 is its biggest answer. A factorial calculator is the right tool for the range most people need, because 0 to 20 covers the homework, the counting problems and the probability examples, and anything bigger is a job for Stirling's approximation or a specialised tool.
Related Calculators and Mathematical Concepts
Three of the four have no page on the site, and one is covered by a combined page, so this section says plainly which is which, and gives the method in the guide where the page does not exist.
Permutation Calculator
There is no separate Permutation Calculator page on the site, and the same is true of the Combination Calculator below, because both are covered by one combined page. The Combination and Permutation Calculator on CalcSolver handles permutations and combinations together, with a repetition switch and a steps panel, and it is the page to use for P(n, r) and C(n, r). The permutation formula is P(n, r) = n! ÷ (n − r)!, and the factorial inside it is what the tool on CalcSolver gives you, so the two tools work as a pair: the factorial tool for n!, and the combined page for the permutation itself.
Combination Calculator
There is no separate Combination Calculator page on CalcSolver either, and it is the same combined page as above that covers it. The Factorial Calculator on CalcSolver gives the three factorials in that formula, so I use it for 52!, 5! and 47!, and do the division by hand, and the answer is a whole number, which is the check that the working is right.
Scientific Calculator
There is no Scientific Calculator page on CalcSolver, so there is no general scientific calculator to link to here. The arithmetic that a scientific calculator would do for a factorial problem is covered by the tools that do exist: the Factorial Calculator on CalcSolver for the n! itself, the Exponent Calculator for powers, and the Scientific Notation Calculator for writing a big answer like 20! as 2.43 × 10^18.
Gamma Function Calculator
There is no Gamma Function Calculator page on CalcSolver, so the Gamma values in this guide are worked by hand and there is no tool to link to. If a Gamma Function Calculator page is added to CalcSolver, it would be the tool for these values, but until then the Gamma section of this guide is the place to find them.
This tool is the one I open first whenever a counting problem appears, because it answers the factorial and shows the working, and the working is what makes the next problem easier. The factorial is a simple idea with a very long reach, and once you can see it in a seating plan, a poker hand and a line of code, it stops being a symbol on a board and becomes a tool you actually use.
