UtilityToolsLab

© 2026 UtilityToolsLab. Built and maintained by the UtilityToolsLab Team.

About·Changelog·Privacy Policy·Terms of Service·Contact
HomeNumber & Base ToolsFactorial Calculator

Related Tools

Matrix CalculatorRandom NumbersDice RollerFibonacci GeneratorPrime Checker

Factorial Calculator — n! with Steps

Compute n! for any n from 0 to 500 using exact BigInt arithmetic. Shows digit count, trailing zeros, Stirling approximation, and a P(n,r)/C(n,r) helper.

You Might Also Like

All Number & Base Tools

Combinatorics

Calculate nCr, nPr, factorials, Catalan numbers and Stirling numbers using exact BigInt arithmetic. Step-by-step working shown for every result.

Matrix Calculator

Add, subtract, multiply, transpose, and find the determinant or inverse of a 2x2 or 3x3 matrix. No data ever leaves your device.

Random Numbers

Free random number generator (RNG) for whole numbers in any range, drawn from your device's cryptographic source, with unique mode and no modulo bias.

Dice Roller

Roll d4 through d100 with standard dice notation like 2d6+3, a running history, and cryptographically random results. No physical dice required.

Factorials grow deceptively fast. 10! = 3,628,800, a number that fits comfortably on screen. 100! has 158 digits. 500! has 1,135. This calculator uses JavaScript BigInt so every digit of every result is exact: no floating-point rounding, no scientific-notation approximations cutting the answer short after 17 significant figures.

Beyond the raw value, the results panel shows how many digits the factorial produces, how many trailing zeros it carries, and (for n ≥ 3) a Stirling approximation so you can compare the exact answer against the asymptotic formula without switching tabs. A built-in permutation and combination helper reuses the same n, so you can answer “how many ways can I arrange 10 cards and choose 3 of them?” in the same tool.

Worked Example: 10 Factorial

Press Load Sample and n becomes 10. The result is 3628800, produced by the chain 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1. The facts panel confirms 7 digits and 2 trailing zeros (from the factor pairs 5×2 and 10×1). The Stirling panel shows 3.5988 × 10^6, which is within 0.83% of the true value.

With r set to 3, the permutation box shows P(10, 3) = 720 (the number of ordered arrangements of 3 items from 10) and the combination box shows C(10, 3) = 120, the number of unordered selections. Both are exact BigInt results, not estimates.

The Formula: Counting Trailing Zeros in n!

A trailing zero in n! comes from a factor of 10 = 2 × 5 in the multiplication. Powers of 2 always outnumber powers of 5 in n!, so the count of trailing zeros equals the total number of times 5 divides into the integers 1 through n. This is Legendre’s formula:

trailing zeros = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …

For n = 100: 20 + 4 + 0 = 24 trailing zeros. The formula runs in O(log n) time, so the result for n = 500 (124 zeros) appears instantly without factoring the full 1,135-digit number.

Precision and Range Notes

  • n = 0 returns 1. Zero factorial is defined as 1 by convention, not a special case added for convenience. It makes the combinatorics formulas consistent: C(n, 0) = n! / (0! × n!) = 1.
  • n is capped at 500. 500! has 1,135 digits. Values above that produce numbers too large to display usefully in a browser. If you see the message “n is capped at 500” your input exceeded the ceiling.
  • The Stirling approximation uses floating-point arithmetic.For n = 10 the relative error is about 0.83%; by n = 100 it falls below 0.09%. The exact BigInt value is always the authoritative answer; Stirling is shown for scale and comparison only.
  • Combinations are computed without cancellation loss.C(n, r) is calculated as (n × (n-1) × … × (n-r+1)) / r!, choosing the smaller of r and n-r to minimise multiplications. For r > n the tool displays “r cannot exceed n for P(n, r).”

Display

10! =

3628800

Expression

10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1

Digits

7

Trailing Zeros

2

Stirling Approx

3.5987 × 10^6

Permutations & Combinations

Uses the same n above. Set r to choose how many you're selecting.

P(10, 3) — Permutations

n! / (n − r)! — ordered arrangements

720

C(10, 3) — Combinations

n! / (r! × (n − r)!) — unordered selections

120