Skip to main content

Factorial Calculator

Calculate factorial (n!), double factorial, and subfactorial for any positive integer. View step-by-step multiplication expansion and applications in permutations and combinations.

Calculate Factorial

Enter a non-negative integer to calculate its factorial and related values

Enter a value from 0 to 10,000

Used for permutations and combinations

Factorial Formulas

Key formulas and definitions

Factorial (n!)

n! = n x (n-1) x (n-2) x ... x 2 x 1

Special case: 0! = 1 (by convention)

Double Factorial (n!!)

n!! = n x (n-2) x (n-4) x ... (down to 1 or 2)

Product of all positive integers up to n with the same parity as n

Subfactorial (!n)

!n = n! x sum((-1)^k / k!) for k from 0 to n

Counts derangements (permutations with no fixed points)

Stirling's Approximation

n! approx sqrt(2*pi*n) x (n/e)^n

Useful approximation for large values of n

About This Calculator

The factorial function is one of mathematics' most fundamental and elegant operations, appearing throughout algebra, calculus, probability theory, and countless practical applications. Denoted by the exclamation mark (n!), a factorial represents the product of all positive integers from 1 up to n. For example, 5! equals 5 times 4 times 3 times 2 times 1, which gives us 120. This seemingly simple operation grows extraordinarily fast - while 10! is a manageable 3,628,800, by the time we reach 20!, we're dealing with a number exceeding 2 quintillion. Factorials form the backbone of combinatorics, enabling us to count permutations and combinations with precision. They're essential in probability calculations, from determining lottery odds to analyzing statistical distributions. In calculus, factorials appear in Taylor series expansions that approximate functions like sine, cosine, and the exponential function. The factorial function extends beyond integers through the gamma function, connecting to complex analysis and advanced mathematics. Understanding factorials opens doors to deeper mathematical concepts while providing practical tools for solving real-world counting and probability problems. For related calculations involving arrangements and selections, check out our Permutation Calculator and Combination Calculator.

Trusted Sources

How to Use the Factorial Calculator

  1. 1Enter values and click calculate

What Is a Factorial?

A factorial, written as n!, is the product of all positive integers from 1 to n. The factorial of 5 is calculated as 5! = 5 x 4 x 3 x 2 x 1 = 120. This operation counts the number of ways to arrange n distinct objects in a sequence. Factorials grow extremely rapidly - 10! equals 3,628,800, while 20! exceeds 2.4 quintillion. The recursive definition states that n! = n x (n-1)!, providing an elegant way to compute factorials step by step. Factorials are defined only for non-negative integers in their basic form, though the gamma function extends this concept to all complex numbers except negative integers. For calculating arrangements where order matters, see our Permutation Calculator.

Why Does 0! Equal 1?

The definition 0! = 1 might seem counterintuitive, but it's mathematically necessary and logically consistent. There is exactly one way to arrange zero objects - by doing nothing. This convention maintains consistency in combinatorial formulas; for instance, C(n,0) = n!/(0! x n!) = 1, correctly indicating there's one way to choose nothing from n items. The recursive formula n! = n x (n-1)! requires 0! = 1 to work properly: 1! = 1 x 0!, so 0! must equal 1. The empty product convention in mathematics defines the product of no numbers as 1, the multiplicative identity. This definition also ensures the gamma function, which extends factorials, remains continuous at x = 1.

Permutations and Combinations

Factorials are essential for counting arrangements and selections. A permutation counts ordered arrangements: the number of ways to arrange r items from n distinct items is P(n,r) = n!/(n-r)!. For example, arranging 3 books from 5 on a shelf has P(5,3) = 5!/2! = 60 possibilities. Combinations count unordered selections: C(n,r) = n!/(r!(n-r)!) gives the number of ways to choose r items from n without regard to order. Choosing 3 committee members from 10 candidates has C(10,3) = 120 possibilities. These formulas underpin probability theory, statistical analysis, and decision-making processes across science and engineering. Use our Combination Calculator for selection problems or the Permutation Calculator for arrangement problems.

Factorials in Probability

Probability calculations frequently require factorials. The binomial distribution uses C(n,k) to determine the probability of exactly k successes in n trials. Lottery odds calculations divide favorable outcomes by total permutations or combinations. The probability of a specific card arrangement in a shuffled deck involves 52! possible orderings - a number so large it's virtually guaranteed no two properly shuffled decks have ever been in the same order. Multinomial coefficients, generalizing combinations, calculate probabilities when items fall into multiple categories. The Poisson distribution uses factorials in its probability mass function, modeling rare events in fields from queuing theory to radioactive decay. For probability distributions, our Z-Score Calculator can help with normal distribution calculations.

Taylor Series and Calculus

Factorials appear prominently in calculus through Taylor series expansions. The exponential function expands as e^x = 1 + x/1! + x^2/2! + x^3/3! + ..., converging for all real x. Similarly, sin(x) = x - x^3/3! + x^5/5! - ..., and cos(x) = 1 - x^2/2! + x^4/4! - .... These series enable precise calculation of transcendental functions and form the basis of numerical methods in computing. The factorial in the denominator ensures convergence by making terms decrease rapidly enough. Maclaurin series, Taylor series centered at zero, use factorials to express functions as infinite polynomials, bridging algebra and analysis. For exponential calculations, try our Exponent Calculator.

Factorials in Nature and Science

Factorial growth patterns appear throughout nature and science. In genetics, the number of possible gene arrangements on chromosomes involves factorial calculations. Chemical isomers of molecules with n substitution sites may number up to n!. Quantum mechanics uses factorials in calculations of particle statistics and wave functions. In computer science, the complexity class of brute-force permutation algorithms is O(n!), representing the ultimate challenge in computational complexity. The traveling salesman problem, with (n-1)!/2 possible routes for n cities, exemplifies why factorial growth makes exhaustive search impractical for large inputs.

Pro Tips

  • 💡**Start with Small Values**: When learning factorials, calculate small values by hand first. 1!=1, 2!=2, 3!=6, 4!=24, 5!=120. This builds intuition for how rapidly factorials grow and helps verify calculator results for larger numbers.
  • 💡**Use the Recursive Property**: Remember that n! = n x (n-1)!. If you know 6! = 720, then 7! = 7 x 720 = 5,040. This property makes mental calculations easier and forms the basis of efficient computer algorithms.
  • 💡**Simplify Before Calculating**: In expressions like 10!/7!, cancel common factors: 10!/7! = 10 x 9 x 8 = 720. This avoids computing large intermediate values and reduces calculation errors. The same principle simplifies permutation and combination formulas.
  • 💡**Memorize Common Factorials**: Knowing factorials up to 10! speeds up calculations: 6!=720, 7!=5,040, 8!=40,320, 9!=362,880, 10!=3,628,800. These values appear frequently in probability and statistics problems and serve as checkpoints for larger calculations.
  • 💡**Use Scientific Notation for Large Results**: Factorials grow faster than exponentials. By 20!, you're dealing with 19 digits. Express large factorials in scientific notation for practical use: 20! is approximately 2.43 x 10^18. This makes comparisons and calculations manageable.
  • 💡**Understand the Permutation-Combination Relationship**: Permutations and combinations are related by P(n,r) = r! x C(n,r). Permutations count ordered arrangements; combinations ignore order. If you know one, divide or multiply by r! to find the other. This relationship helps verify calculations.
  • 💡**Apply the Complement Rule**: Sometimes it's easier to count what you don't want. The number of arrangements with at least one item in its original position equals n! minus the subfactorial !n. This complement approach simplifies many counting problems.
  • 💡**Use Stirling's Approximation**: For very large n, use Stirling's formula: n! is approximately sqrt(2*pi*n) x (n/e)^n. This gives quick estimates when exact values are impractical. The approximation improves as n increases, with relative error decreasing like 1/(12n).
  • 💡**Check Reasonableness of Answers**: Factorial results should always be positive integers. If calculating combinations or permutations, results must be positive integers less than or equal to n!. If you get a negative, fractional, or impossibly large result, recheck your calculation.
  • 💡**Recognize Factorial Growth**: Factorial growth outpaces exponential growth for large n. While 2^10 = 1,024, we have 10! = 3,628,800. This has practical implications: algorithms with O(n!) complexity become infeasible quickly. Recognize when a problem's factorial nature limits practical solution sizes.
  • 💡**Use Double Factorials for Specific Problems**: Double factorials appear in physics and statistics. For odd n, n!! = 1 x 3 x 5 x ... x n gives the product of odd integers. For the normal distribution, moments involve double factorials. Recognize when this specialized form applies to your problem.
  • 💡**Connect to the Gamma Function**: The gamma function generalizes factorials: gamma(n+1) = n! for positive integers. This connection extends factorial concepts to non-integers and appears in advanced probability distributions, physics, and engineering. Understanding this link opens doors to more sophisticated mathematics.

Frequently Asked Questions

A factorial of a non-negative integer n, written as n!, is the product of all positive integers from 1 to n. To calculate 5!, multiply 5 x 4 x 3 x 2 x 1 = 120. Factorials count the number of ways to arrange n distinct objects in order. The value grows extremely rapidly: 10! = 3,628,800 and 20! exceeds 2 quintillion.

NB
Written byNina Bao
Updated January 16, 2026

More Calculators You Might Like