Factorial Calculator
Calculate factorial instantly with our math tool. Shows detailed work, formulas used, and multiple solution methods. Free to use with no signup required.
Reviewed for accuracy by Manoj Kumar, Mathematics Educator
Factorial Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser โ no data is sent to any server.
Formula: n! = n * (n-1) * (n-2) * ... * 2 * 1
Worked example โ 8! = 40,320 | 1 trailing zero | 5 digits
Formula
n! = n * (n-1) * (n-2) * ... * 2 * 1
Where n! (n factorial) is the product of all positive integers from 1 to n. By convention, 0! = 1. Factorials count the number of ways to arrange n distinct objects in order (permutations).
Worked Examples
Example 1: Computing 8! with Trailing Zeros
Problem:Calculate 8! and determine how many trailing zeros it has.
Solution:8! = 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 = 56 * 6 * 5 * 4 * 3 * 2 * 1 = 336 * 5 * 4 * 3 * 2 * 1 = 1,680 * 4 * 3 * 2 * 1 = 6,720 * 3 * 2 * 1 = 20,160 * 2 * 1 = 40,320 Trailing zeros: floor(8/5) = 1 8! = 40,320 has 1 trailing zero
Result:8! = 40,320 | 1 trailing zero | 5 digits
Example 2: Factorials in Combinations
Problem:How many ways can you choose 3 items from 10? Use the combination formula with factorials.
Solution:C(10, 3) = 10! / (3! * 7!) = 3,628,800 / (6 * 5,040) = 3,628,800 / 30,240 = 120 Alternatively: (10 * 9 * 8) / (3 * 2 * 1) = 720 / 6 = 120
Result:C(10,3) = 10! / (3! * 7!) = 120 ways
Frequently Asked Questions
What is a factorial and how is it calculated?
A factorial of a non-negative integer n, denoted as n!, is the product of all positive integers from 1 to n. For example, 5! = 5 * 4 * 3 * 2 * 1 = 120. By mathematical convention, 0! is defined as 1, which is called the empty product. This definition is necessary to make many formulas in combinatorics and calculus work correctly. Factorials grow extremely rapidly: 10! = 3,628,800, 15! = 1,307,674,368,000, and 20! = 2,432,902,008,176,640,000. This explosive growth rate makes factorials one of the fastest-growing functions commonly encountered in mathematics. The factorial function is central to permutations, combinations, and probability theory.
Why is 0 factorial equal to 1?
The definition 0! = 1 follows logically from the recursive definition of factorials and from combinatorial reasoning. The recursive formula states n! = n * (n-1)!. If we apply this with n = 1: 1! = 1 * 0!, which gives 1 = 1 * 0!, so 0! must equal 1. From a combinatorics perspective, 0! counts the number of ways to arrange zero objects, and there is exactly one way to arrange nothing: do nothing. This is the empty permutation. Additionally, the binomial coefficient C(n, 0) = n! / (0! * n!) must equal 1 (there is one way to choose nothing), which requires 0! = 1. The gamma function, which extends factorials to non-integers, also gives the value 1 at the point corresponding to 0!.
What is the relationship between factorials and permutations?
Factorials directly count the number of permutations (ordered arrangements) of n distinct objects. If you have n different items and want to arrange all of them in a row, there are n! possible arrangements. The first position has n choices, the second has n-1 remaining choices, the third has n-2, and so on, giving n * (n-1) * (n-2) * ... * 2 * 1 = n!. For partial permutations (choosing and arranging r items from n), the formula is P(n,r) = n! / (n-r)!. For example, arranging 3 items from 5 gives P(5,3) = 5! / 2! = 120 / 2 = 60. This connection makes factorials indispensable in probability calculations and counting problems.
What is Stirling approximation for factorials?
Stirling approximation is a formula that estimates n! for large values of n without computing the exact product. The basic form is n! is approximately equal to the square root of (2 * pi * n) times (n/e)^n, where e is Euler's number (approximately 2.71828). For n = 10, the exact value is 3,628,800 and Stirling gives about 3,598,696, which is 99.2% accurate. The approximation becomes more precise as n increases. For n = 100, the relative error is less than 0.1%. This formula is essential in statistical mechanics, information theory, and asymptotic analysis, where exact factorials are impractical to compute. More refined versions include correction terms for better accuracy.
How do you count trailing zeros in a factorial?
Trailing zeros in n! are produced by factors of 10, and each factor of 10 comes from pairing a factor of 2 with a factor of 5. Since factors of 2 are always more abundant than factors of 5 in n!, the number of trailing zeros equals the number of times 5 appears in the prime factorization of n!. This is calculated using Legendre formula: floor(n/5) + floor(n/25) + floor(n/125) + ... For example, 100! has floor(100/5) + floor(100/25) + floor(100/125) = 20 + 4 + 0 = 24 trailing zeros. The first term counts multiples of 5, the second counts multiples of 25 (which contribute an extra factor of 5), and so on for higher powers of 5.
What is the gamma function and how does it extend factorials?
The gamma function, denoted by the Greek capital letter gamma, extends the factorial to all complex numbers except negative integers. For positive integers, the gamma function satisfies the identity gamma(n) = (n-1)!. So gamma(5) = 4! = 24 and gamma(1) = 0! = 1. The gamma function is defined by an integral: gamma(z) = integral from 0 to infinity of t^(z-1) * e^(-t) dt. This allows computing factorials for non-integer values. For example, gamma(1/2) = square root of pi, which means (-1/2)! = square root of pi in an extended sense. The gamma function appears throughout mathematics and physics, particularly in probability distributions, quantum mechanics, and complex analysis.
What are double factorials and how are they different?
A double factorial, denoted n!!, is the product of all positive integers up to n that have the same parity (odd or even) as n. For odd n: n!! = n * (n-2) * (n-4) * ... * 3 * 1. For even n: n!! = n * (n-2) * (n-4) * ... * 4 * 2. For example, 7!! = 7 * 5 * 3 * 1 = 105 and 8!! = 8 * 6 * 4 * 2 = 384. Note that n!! is NOT the same as (n!)!. Double factorials appear in formulas for the volume of n-dimensional spheres, in quantum mechanics (Wick's theorem), and in combinatorics. They satisfy the identity n! = n!! * (n-1)!!, and the relationship between double factorial and regular factorial involves the gamma function at half-integer values.
How fast do factorials grow compared to exponential functions?
Factorials grow much faster than any exponential function. While 2^n doubles with each step and 10^n grows by a factor of 10, n! grows by a factor of n at each step, which itself increases. At n = 10: 2^10 = 1,024, 10^10 = 10 billion, but 10! = 3.6 million. By n = 20: 2^20 is about 1 million, 10^20 = 100 quintillion, and 20! is about 2.4 quintillion. At n = 25, factorial overtakes 10^n: 25! is about 1.55 * 10^25, which exceeds 10^25. By n = 100, 100! has 158 digits while 10^100 has only 101 digits. This super-exponential growth rate makes exact computation of large factorials computationally challenging.
What are the practical applications of factorials in real life?
Factorials are used extensively in probability, statistics, and computer science. In probability, the number of ways to shuffle a deck of 52 cards is 52!, an astronomically large number with 68 digits. In statistics, factorials appear in the binomial distribution formula C(n,k) = n! / (k!(n-k)!) and in the calculation of p-values. Computer scientists use factorials to analyze algorithm complexity: algorithms that check all permutations run in O(n!) time, which is why brute-force solutions to the traveling salesman problem are impractical for large inputs. Factorials also appear in Taylor series expansions (e^x = sum of x^n/n!), quantum mechanics, and cryptography, where the security of some systems depends on the infeasibility of checking all permutations.
References
Reviewed for accuracy by Manoj Kumar, Mathematics Educator ยท Editorial policy
Related Calculators
๐งฎAnnulus Area Calculator
Calculate annulus area with inputs, formulas, and instant results.
๐งฎArea Calculator
Calculate area with inputs, formulas, and instant results.
๐งฎArea of a Rectangle Calculator
Calculate the area, perimeter, and diagonal of a rectangle. Find missing sides from known area. Convert between metric and imperial area units.
๐งฎArea of Crescent Calculator
Calculate area of crescent with inputs, formulas, and instant results.
๐งฎCenter of Mass Calculator
Calculate center of mass with inputs, formulas, and instant results.
๐งฎCentroid Calculator
Calculate centroid with inputs, formulas, and instant results.
๐งฎChord Length Calculator
Calculate chord length with inputs, formulas, and instant results.
๐งฎConic Sections Calculator
Calculate conic sections with inputs, formulas, and instant results.