Factorial Calculator — Compute n! with Steps
Calculate the factorial of any number from 0 to 170. Shows the step-by-step multiplication, digit count, and trailing zeros.
Factorial
Results update instantly as you type
Enter Values
Embed Code
Copy and paste this HTML snippet into any web page to embed this calculator directly.
<iframe src="http://127.0.0.1:54963/embed/math/factorial-calculator?ref=embed" title="Factorial Calculator — Compute n! with Steps" width="100%" style="max-width:600px; border:none; height:500px;" loading="lazy"></iframe>
Direct Link
Share this link to let others open the calculator in their browser.
The Formula
The factorial of a non-negative integer n, denoted n!, is the product of all positive integers less than or equal to n. By definition, 0! = 1. Factorials grow extremely fast — 10! = 3,628,800 and 20! is already over 2.4 quintillion. The factorial function is defined recursively as n! = n x (n-1)! with the base case 0! = 1. For n = 0, the empty product is defined as 1, which is consistent with combinatorial formulas and infinite series.
Variable Definitions
Factorial of n
The product of all positive integers from 1 to n. Pronounced "n factorial." For n = 0, the result is defined as 1.
Input Number
A non-negative integer whose factorial is being computed. Must be between 0 and 170 for JavaScript to maintain precision.
Digit Count
The number of decimal digits in n!. For large n, this can be computed approximately using Kamenetsky's formula: d = floor(n * log10(n/e) + log10(2*pi*n)/2) + 1.
Trailing Zeros
The number of zeros at the end of n! in decimal representation. Determined by counting factors of 5 in the prime factorization of n!.
How to Use This Calculator
- 1
Enter a non-negative integer n (from 0 to 170) in the input field.
- 2
View the factorial result displayed with comma separators for readability.
- 3
Read the step-by-step multiplication showing how each term contributes to the final product.
- 4
Check the digit count to understand how large the factorial result is.
- 5
See the trailing zeros count, which reveals how many times 10 divides the factorial.
Quick Reference
| From | To |
|---|---|
| 0! | 1 (by definition) |
| 1! | 1 |
| 5! | 120 |
| 10! | 3,628,800 |
Common Applications
- Permutations and combinations: n! is the number of ways to arrange n distinct objects, and appears in nPr and nCr formulas.
- Probability and statistics: factorial appears in binomial coefficients, Poisson distributions, and Bayesian inference.
- Calculus: factorials appear in Taylor series expansions for e^x, sin(x), cos(x), and many other functions.
- Number theory: factorials are used in Wilson's theorem for primality testing and studying prime distributions.
- Computer science: factorial growth models the worst-case complexity of certain algorithms and appears in asymptotic analysis.
Factorial values from 0! to 10!. Note how quickly the values grow: 0! and 1! are 1, but 10! is already 3,628,800.
Understanding the Concept
The factorial function is one of the most important functions in mathematics, appearing throughout combinatorics, algebra, analysis, and number theory. For a non-negative integer n, the factorial n! is defined as the product of all positive integers from 1 to n: n! = n x (n-1) x (n-2) x ... x 2 x 1. The special case 0! = 1 is defined for consistency — it makes combinatorial formulas work (there is exactly one way to arrange zero objects, and the binomial coefficient (0 choose 0) = 1). Factorials grow at an astonishing rate. While 5! = 120 is modest, 10! = 3,628,800, 15! = 1,307,674,368,000, and 20! = 2,432,902,008,176,640,000. By 170!, the value exceeds 10^306, which is the limit of JavaScript's 64-bit floating-point precision (Number.MAX_VALUE is about 1.79 x 10^308). Beyond 170, the factorial overflows to Infinity. The number of trailing zeros in n! can be found without computing the full factorial: count how many factors of 5 appear in the numbers 1 through n (since factors of 2 are always more abundant). This is computed as floor(n/5) + floor(n/25) + floor(n/125) + ... For example, 25! has 6 trailing zeros: floor(25/5) = 5 from multiples of 5, plus floor(25/25) = 1 from the extra factor of 5 in 25 itself. The digit count of n! can be approximated using Stirling's approximation: n! ~ sqrt(2*pi*n) x (n/e)^n, which gives ln(n!) ~ n*ln(n) - n + 0.5*ln(2*pi*n). Taking log10 gives the number of decimal digits.
Frequently Asked Questions
Sources & References
Related Calculators
Reviews
No reviews yet. Be the first to share your experience with Factorial Calculator — Compute n! with Steps.
Write a Review
