Factorial Calculator

Calculate n! or n!! with exact integer output for practical inputs, scientific notation, digit count, trailing zeros, prime factorization and a transparent product expansion.

Factorial result

Number of digits0
Trailing zeros0
Scientific notation0
Factorial n!0

Enter a nonnegative integer. Standard factorial is defined here for n = 0, 1, 2, …, with 0! = 1.

Exact integer

0

Calculation breakdown

Input n0
Operation0
Product expansion0
Prime factorization0
log₁₀(result)0
Recurrence check0

Transparent formula

n! = n × (n−1) × … × 2 × 1

0! = 1

trailing zeros = Σ floor(n / 5ᵏ)

digits = floor(log₁₀(n!)) + 1

What is a factorial?

The factorial of a nonnegative integer n is the product of every positive integer from n down to 1. It is written n! and grows extremely quickly.

n! = n × (n−1) × (n−2) × … × 3 × 2 × 1

For example:

5! = 5 × 4 × 3 × 2 × 1 = 120

Factorials appear throughout combinatorics, probability, algebra, calculus, numerical methods and computer science. They count arrangements, appear in binomial coefficients, and form the denominators of many power-series terms.

Why is 0! equal to 1?

By definition, 0! = 1. This is not an arbitrary exception. It keeps the factorial recurrence consistent:

n! = n × (n−1)!

Set n = 1:

1! = 1 × 0!

Since 1! = 1, it follows that 0! must equal 1. It also matches combinatorics: there is exactly one way to arrange zero objects—the empty arrangement.

Factorial examples

nn!Expansion
01Empty product
111
222 × 1
363 × 2 × 1
4244 × 3 × 2 × 1
51205 × 4 × 3 × 2 × 1
103,628,80010 × 9 × … × 1
202,432,902,008,176,640,00020 × 19 × … × 1

How this factorial calculator works

For practical integer inputs, SonoCalculator uses exact integer arithmetic rather than ordinary floating-point multiplication. That matters because standard floating-point numbers cannot represent very large factorials exactly.

The calculator also derives useful properties from the same input: digit count, scientific notation, trailing zeros, a readable product expansion, a prime factorization for manageable n and the base-10 logarithm of the result.

Exact factorial versus scientific notation

Factorials become large so quickly that the full integer can be difficult to read. Scientific notation compresses the value into a significand and a power of ten:

100! ≈ 9.332621544 × 10¹⁵⁷

The exact integer is still useful when a problem requires every digit. Scientific notation is better for understanding scale. This calculator shows both when exact computation is practical.

How many digits are in n!?

If n! is known through its base-10 logarithm, the number of decimal digits is:

digits(n!) = floor(log₁₀(n!)) + 1

For n ≥ 1:

log₁₀(n!) = Σ from k=1 to n of log₁₀(k)

This avoids first writing the full integer just to learn its length. For very large n, logarithmic or gamma-based methods are much more practical than expanding every digit.

Trailing zeros in a factorial

A decimal trailing zero comes from a factor of 10 = 2 × 5. Factorials contain many more factors of 2 than factors of 5, so the number of trailing zeros in n! is controlled by the number of factors of 5.

zeros(n!) = floor(n/5) + floor(n/25) + floor(n/125) + …

The series stops when the denominator exceeds n. For 100!:

floor(100/5) + floor(100/25) = 20 + 4 = 24

Therefore 100! ends in 24 zeros.

Prime factorization of n!

The exponent of a prime p in n! can be found with Legendre's formula:

vₚ(n!) = floor(n/p) + floor(n/p²) + floor(n/p³) + …

For example, the exponent of 2 in 10! is floor(10/2) + floor(10/4) + floor(10/8) = 5 + 2 + 1 = 8. The exponent of 5 is floor(10/5) = 2.

So part of the prime factorization is 2⁸ × 5², with the remaining prime factors supplied by 3 and 7. Prime-exponent form is especially useful when simplifying ratios of factorials.

Factorial recurrence

The defining recurrence is:

n! = n × (n−1)!

This lets a known factorial generate the next one. For example, 8! = 8 × 7! = 8 × 5,040 = 40,320.

The same recurrence is useful as a consistency check for computed values.

What is double factorial?

Double factorial uses two exclamation marks but is not “factorial applied twice.” It skips every other integer:

n!! = n × (n−2) × (n−4) × …

For even n, multiplication ends at 2. For odd positive n, it ends at 1.

8!! = 8 × 6 × 4 × 2 = 384 7!! = 7 × 5 × 3 × 1 = 105

By standard convention, 0!! = 1. The calculator's double-factorial mode uses nonnegative integers, which covers the ordinary discrete use case.

Factorial and double factorial are different operations

For n = 6:

6! = 6 × 5 × 4 × 3 × 2 × 1 = 720 6!! = 6 × 4 × 2 = 48

Because double factorial skips alternate factors, it grows more slowly than the ordinary factorial for the same positive n.

Factorials in permutations

The number of ways to arrange n distinct objects is n!. If five different books can be placed on a shelf in any order, there are:

5! = 120 arrangements

If only r positions are filled from n distinct objects and order matters, permutations use:

P(n,r) = n! / (n−r)!

This is one reason factorial ratios appear so often in counting problems.

Factorials in combinations

When order does not matter, combinations use:

C(n,r) = n! / (r!(n−r)!)

For example, choosing 2 objects from 5 gives 5!/(2!3!) = 10 combinations.

When computing large combinations programmatically, it is often better to cancel factors before constructing huge factorials.

Factorials in probability

Factorials appear in discrete probability distributions and counting arguments. The binomial coefficient in the binomial distribution is one familiar example. The Poisson probability mass function also contains k! in the denominator.

The factorial itself is purely mathematical; the interpretation depends on the probability model.

Factorials in power series

Many important functions have Taylor or Maclaurin expansions containing factorial denominators. For example:

eˣ = 1 + x + x²/2! + x³/3! + …

Because factorials grow rapidly, these denominators strongly reduce higher-order terms for fixed x.

Connection between factorial and the gamma function

The gamma function extends the factorial relationship beyond nonnegative integers. For nonnegative integer n:

n! = Γ(n + 1)

This identity is standard in analysis. It does not mean that the ordinary discrete definition “multiply all positive integers down to 1” directly applies to arbitrary real numbers; gamma is the extension that preserves the relevant recurrence structure.

Why negative integers do not have ordinary factorials

The ordinary factorial n! is defined for nonnegative integers. Extending through Γ(n+1) does not assign finite factorial values to negative integers because the gamma function has poles at the corresponding nonpositive integer arguments.

Therefore this calculator rejects negative n rather than inventing a result.

Why decimal inputs are rejected

The standard factorial mode here is deliberately discrete: n must be a nonnegative integer. A decimal such as 4.5 does not have an ordinary finite product 4.5 × 3.5 × … × 1 in the factorial sense.

Special-function calculations involving gamma are a separate mathematical task and should be labeled clearly rather than silently treating every decimal as an “ordinary factorial.”

How fast do factorials grow?

Factorial growth is faster than any fixed-base exponential cⁿ. Even relatively small values become enormous: 20! already exceeds 2 quintillion.

For understanding large n, Stirling's approximation is fundamental:

n! ≈ √(2πn)(n/e)ⁿ

The approximation becomes more accurate as n grows and is particularly useful for logarithms, order-of-magnitude estimates and asymptotic analysis.

Logarithmic form of Stirling's approximation

Taking natural logs gives:

ln(n!) ≈ n ln n − n + ½ln(2πn)

Logarithms let software estimate the scale of huge factorials without storing every decimal digit. This is also useful for comparing products that would overflow ordinary numeric types.

Factorial overflow in programming

In many programming languages, fixed-size integer types overflow surprisingly early. A signed 64-bit integer can store 20!, but 21! is already too large. Ordinary IEEE-754 double-precision floating point eventually overflows at much larger n and loses exact integer precision long before then.

Arbitrary-precision integers solve the exact-integer problem at the cost of increasing memory and computation as n grows.

Why this calculator limits giant exact output

There is a difference between a mathematically valid result and a useful browser display. A factorial with tens or hundreds of thousands of digits can freeze a page, consume memory and provide little practical value to a reader.

For manageable inputs, SonoCalculator computes and displays the exact integer. For very large inputs, a well-designed calculator should prefer scale information such as digit count and scientific notation rather than pretending that rendering an enormous text block improves usability.

Common factorial mistakes

How to verify a factorial answer

For small n, write the product explicitly. For larger n, use the recurrence n! = n(n−1)! as a check against a neighboring value. Digit counts can be cross-checked with logarithms, and trailing zeros can be independently verified using powers of 5.

Another useful identity is:

(n+1)! = (n+1)n!

If two adjacent factorials do not satisfy that relationship, at least one value is wrong.

Frequently asked questions

What is the factorial of 0?

0! = 1 by definition.

What is 5!?

5! = 5 × 4 × 3 × 2 × 1 = 120.

What is 10!?

10! = 3,628,800.

Can factorials be negative?

Ordinary factorial is defined for nonnegative integers. Negative integers do not have finite values under the gamma-function extension either.

Can I take the factorial of a decimal?

Not with the ordinary discrete definition used here. The gamma function provides a related extension to many noninteger values.

What is the difference between n! and n!!?

n! multiplies every positive integer down to 1; n!! multiplies every second integer.

How do I count zeros at the end of n!?

Add floor(n/5), floor(n/25), floor(n/125) and so on until the denominator exceeds n.

Why do factorials appear in combinations?

They count orderings. Dividing by factorials removes arrangements that represent the same unordered selection.

What is the gamma-function relationship?

For every nonnegative integer n, n! = Γ(n+1).

Does this calculator use rounded values?

Exact mode uses arbitrary-precision integer arithmetic for practical n. Scientific notation and logarithmic summaries are displayed separately.

Final note: factorials are simple products with unusually fast growth. For exact discrete work, keep n nonnegative and integral, preserve integer precision, and distinguish ordinary factorial from double factorial and gamma-function extensions. This calculator surfaces the exact value, scale, trailing zeros and structure together so the result is easier to verify and use.