Skip to main contentSkip to secondary navigation
HomemathFactorial

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.

✓ Formula verified: January 2026
📐

Factorial

Results update instantly as you type

Enter Values

The Formula

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

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

n!

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.

n

Input Number

A non-negative integer whose factorial is being computed. Must be between 0 and 170 for JavaScript to maintain precision.

d

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.

z

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. 1

    Enter a non-negative integer n (from 0 to 170) in the input field.

  2. 2

    View the factorial result displayed with comma separators for readability.

  3. 3

    Read the step-by-step multiplication showing how each term contributes to the final product.

  4. 4

    Check the digit count to understand how large the factorial result is.

  5. 5

    See the trailing zeros count, which reveals how many times 10 divides the factorial.

Quick Reference

FromTo
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

Related Calculators

Reviews

No reviews yet. Be the first to share your experience with Factorial Calculator — Compute n! with Steps.

Write a Review

Your Rating *

0/1000

0/50

Related Calculators

Medical Disclaimer: The health and fitness calculators on this site are for informational and educational purposes only. They are not a substitute for professional medical advice, diagnosis, or treatment. Always consult a qualified healthcare provider with any questions about your health.

Financial Disclaimer: The finance calculators on this site are for informational purposes only and do not constitute financial advice. Results are estimates based on the inputs provided and may vary. Consult a qualified financial advisor before making investment or financial decisions.

© 2026 TheCalcUniverse. All results are for informational purposes only.

Fast, free, and privacy-first.