Sign up

Factorial

Calculate n!, trailing zeros, and scientific notation.

Integer Input

Enter a non-negative integer to compute factorial.

Exact Result
—

Calculation Breakdown:

Enter value to compute.

Details
—
Compute factorials for non-negative integers.

About this topic

Factorial (n!) The product of all positive integers up to n.

The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. It is fundamental in combinatorics and probability.

Key formulas & rules

  • •Formula: n! = n × (n-1) × ... × 1
  • •0! is defined as 1
  • •Grows extremely fast (super-exponential)
  • •Used in permutations and combinations
  • •Only defined for non-negative integers
  • •Calculated using BigInt for accuracy

Examples

Input Output Note
3! 6 3×2×1
5! 120 5×4×3×2×1
0! 1 By definition
10! 3,628,800 Grows fast

Real-world uses

Combinatorics Probability Taylor series
Trailing Zeros Counting the number of zeros at the end of n!.

Trailing zeros in n! are created by multiplying factors of 10, which come from pairs of 2s and 5s. Since there are always more 2s than 5s, the number of trailing zeros is determined by the number of factors of 5.

Key formulas & rules

  • •Counted via Legendre's formula
  • •Formula: floor(n/5) + floor(n/25) + floor(n/125) + ...
  • •Does not require calculating the full factorial
  • •Useful for large n where n! overflows
  • •Zero only occurs when n < 5

Examples

Input Output Note
5! 1 zero 120
10! 2 zeros 3,628,800
25! 6 zeros 5 + 1
4! 0 zeros 24

Real-world uses

Algorithm analysis Competitive programming Number theory
Number of Digits Calculating the length of n! without computing it.

For very large factorials, finding the exact number of digits is done using the sum of logarithms: floor(log10(1) + log10(2) + ... + log10(n)) + 1.

Key formulas & rules

  • •Uses properties of logarithms
  • •Formula: ⌊log₁₀(n!)⌋ + 1
  • •Avoids computing the full factorial
  • •Scales logarithmically
  • •Essential for BigInt limits

Examples

Input Output Note
5! 3 digits 120
10! 7 digits 3628800
50! 65 digits Huge number
100! 158 digits Massive

Real-world uses

Scientific computing Cryptography Data limits

Modes & formulas

1

Compute n!

• Factorial multiplies every positive integer from 1 through n. • Enter a non-negative integer up to 170. • The calculator uses BigInt arithmetic to compute the exact factorial without overflow. • It also reports trailing zeros, digit count, and scientific notation.
n! = n × (n − 1) × (n − 2) × ... × 2 × 1

0! is defined as 1. Trailing zeros are counted efficiently via Legendre's formula without computing the full factorial.

How to use it

Enter a whole number (0–170) and click Calculate. Use the cheat-sheet modal to view the factorial table up to 30!.

Frequently asked questions

Why is 0! equal to 1?
By convention (and to make combinatorial formulas consistent), the empty product equals 1.
Why is 170 the limit?
171! overflows JavaScript's Number range. The calculator uses BigInt, but 170 is the largest input that fits the standard display format.
What is a factorial?
The factorial of a non-negative integer n, denoted as n!, is the product of all positive integers less than or equal to n.
What is the largest number this calculator can handle?
It supports inputs up to 170. Anything larger (171!) exceeds the maximum limit of standard JavaScript numbers and returns Infinity.
What are trailing zeros in a factorial?
They are the zeros at the end of the number. They are created by multiplying factors of 10, which come from pairs of 2s and 5s.
How are trailing zeros calculated?
Using Legendre’s formula: floor(n/5) + floor(n/25) + floor(n/125) + ... This counts the number of factors of 5 without calculating the full factorial.

Related calculators

Read the full Factorial guide — examples & 18 FAQs