Calculadora de Fatorial

A Calculadora de Fatorial calcula n! (n fatorial) — produto de todos os inteiros positivos de 1 a n. Por convenção, 0! = 1.

Try a worked example

Como usar

  1. 1

    Insira um inteiro não negativo n — por exemplo, 10.

  2. 2

    O fatorial aparece instantaneamente: 10! = 3.628.800.

  3. 3

    Abaixo do resultado você verá a contagem de dígitos e a aproximação científica.

  4. 4

    Para n muito grandes (acima de 170), apenas a forma científica é mostrada.

  5. 5

    Toque em um exemplo para ver fatoriais clássicos.

Perguntas frequentes

Ratings & Reviews

Rate this tool

Sign in to rate and review this tool.

Loading reviews…

What is a factorial?

The factorial of a non-negative integer n, written as n! and read as "n factorial," is the product of every positive integer from 1 up to n. So:

  • 1! = 1
  • 2! = 2 × 1 = 2
  • 3! = 3 × 2 × 1 = 6
  • 4! = 4 × 3 × 2 × 1 = 24
  • 5! = 5 × 4 × 3 × 2 × 1 = 120

The factorial counts the number of ways to arrange n distinct items in order. There's 1 way to arrange one item (just leave it). There are 2 ways to arrange two items (AB or BA). There are 6 ways to arrange three items (ABC, ACB, BAC, BCA, CAB, CBA). The factorial is the building block of permutations and combinations — almost any counting problem ends up multiplying or dividing factorials.

By convention, 0! = 1. There's exactly one way to arrange zero items: the empty arrangement. This convention seems weird at first, but it makes the formulas for combinations and Taylor series work without special cases.

How to use the factorial calculator

  1. Enter a non-negative integer n in the field — anything from 0 to 1000.
  2. The factorial appears instantly. For n ≤ 170, you get the exact value with full precision (using JavaScript BigInt arithmetic).
  3. Above n = 170, the exact result has more digits than fit in a normal display, so the calculator shows just the scientific approximation (e.g., "5.07 × 10²⁹⁰" for 200!).
  4. Below the headline value, you'll see the total digit count and a scientific-notation summary (useful for getting a sense of scale even for small inputs).
  5. Tap a worked example to load classic values — 5!, 10!, 13! (the largest that fits in a 32-bit integer), 20!, and 52! (the famous "shuffled deck of cards" number).

Worked examples

Example 1 — 5! (the schoolbook example)

5! = 5 × 4 × 3 × 2 × 1 = 120. Three digits. There are exactly 120 ways to arrange a 5-item list in order. If you have 5 books to put on a shelf, that's 120 different orderings. If you have 5 people to seat in a row, same number.

Example 2 — 10! (the integer-overflow gateway)

10! = 3,628,800. Seven digits. About 3.6 million. Already too big to remember by heart, but still small enough that any calculator can handle it as a regular integer. Most computer science courses use 10! as the example where "iterative multiplication" starts to seem impressive.

Example 3 — 13! (the 32-bit boundary)

13! = 6,227,020,800. Ten digits, just over 6 billion. This is the largest factorial that fits in a 32-bit signed integer (max value 2,147,483,647). 14! overflows. Many older programming languages and embedded systems can't compute beyond 12! or 13! without special arithmetic.

Example 4 — 20! (the 64-bit boundary)

20! = 2,432,902,008,176,640,000 ≈ 2.43 × 10¹⁸. About 2.4 quintillion. This is the largest factorial that fits in a 64-bit signed integer (max ≈ 9.2 × 10¹⁸). 21! overflows even 64-bit.

Example 5 — 52! (the shuffled deck)

52! ≈ 8.07 × 10⁶⁷. A 68-digit number. This is the number of distinct ways a standard 52-card deck can be ordered. The number is so large that if everyone on Earth had been shuffling decks once per second since the Big Bang, we still wouldn't have shuffled the same arrangement twice. Every well-shuffled deck you've ever seen is — to a virtual certainty — an arrangement that has never existed before in the history of the universe and will never exist again.

Example 6 — 100! (just because)

100! ≈ 9.33 × 10¹⁵⁷. A 158-digit number. The exact value: 9332621544394415268169923885626670049071596826438162146859296389521759999322991560894146397615651828625369792082722375825118521091686400000000000000000000000000.

How fast factorials grow

Faster than almost anything else you'll encounter in regular math. Comparing growth rates at n = 50:

  • n = 50
  • n² = 2,500
  • n³ = 125,000
  • 2ⁿ = 1.13 × 10¹⁵
  • nⁿ = 8.88 × 10⁸⁴
  • n! = 3.04 × 10⁶⁴

Notice that n! sits between 2ⁿ (which gets all the attention as "exponential") and nⁿ (which is even more aggressive). At small n, exponentials feel huge; at moderately large n, factorials catch up and pass them. By n = 50, n! is 30 orders of magnitude bigger than 2ⁿ.

This is why algorithms with factorial time complexity (O(n!)) are considered intractable past about n = 10 or 11. The traveling salesman problem solved by brute-force permutation enumeration is O(n!) — feasible for 8 cities (40,320 routes), painful for 12 (479 million), impossible for 20 (2.4 quintillion).

Where factorials show up

Permutations and combinations

If you're choosing or arranging items, factorials appear:

  • Permutations: P(n, k) = n! / (n − k)!. The number of ways to choose k items from n and put them in order.
  • Combinations: C(n, k) = n! / (k! × (n − k)!). The number of ways to choose k items from n where order doesn't matter (think Powerball: the order of your numbers doesn't matter, only which six numbers).
  • Anagrams: For a word with n distinct letters, there are n! anagrams. The word "FACTOR" has 6! = 720 distinct rearrangements.

Probability

The Poisson distribution uses k! in the denominator: P(X = k) = (λᵏ × e⁻ᵏ) / k!. The hypergeometric, multinomial, and many other discrete distributions also rely on factorials.

Calculus

Taylor series approximate any smooth function as an infinite sum where each term divides by k!:

eˣ = 1 + x + x²/2! + x³/3! + x⁴/4! + ...

sin(x) = x − x³/3! + x⁵/5! − x⁷/7! + ...

The factorials in the denominator are what make these series converge — without them, the terms grow too fast.

Computer science

Algorithm analysis (O(n!) for brute-force permutation problems), data structures (counting binary trees, graph isomorphisms), and cryptography (counting key spaces). Many "intractable" problems have factorial time complexity in the worst case.

Card games and shuffling

52! ≈ 8 × 10⁶⁷ is the number of orderings of a standard deck. Once a deck is properly shuffled (typically 7 riffle shuffles), the resulting order is, with overwhelming probability, an arrangement that has never existed before and never will again. This is the number that gives "every deck is unique" its mathematical force.

Stirling's approximation

For very large n, an exact factorial is rarely useful — the number is too big to do anything with. The standard approximation is Stirling's formula:

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

For n = 100: Stirling gives 9.32 × 10¹⁵⁷, very close to the true 9.33 × 10¹⁵⁷ — a relative error of about 0.1%. The approximation gets better as n grows. It's the standard tool for estimating factorial-sized quantities in physics, statistics, and asymptotic analysis.

Common mistakes

  • Trying to take the factorial of a non-integer. The basic factorial is defined for non-negative integers only. For real or complex inputs, you need the gamma function: Γ(n + 1) = n!. The calculator restricts inputs to non-negative integers to avoid confusion.
  • Forgetting that 0! = 1. Many algorithms break if you assume 0! = 0. The convention is established and necessary for combinations to work.
  • Underestimating growth. "How big could 20! really be?" 2.4 quintillion. "What about 100!?" 158 digits. Factorials are the sandbag growth rate.
  • Using regular floats for large n. Past 13!, you'll lose precision in standard JavaScript Numbers. The calculator uses BigInt to preserve exactness up to n = 170.
  • Confusing factorial with double-factorial. n!! (double factorial) means n × (n−2) × (n−4) × ... — only every other integer. 5!! = 5 × 3 × 1 = 15, not 5! × 5! = 14,400. Different operation, similar notation.

What the calculator gives you, summarized

  • Exact value — n! computed precisely using BigInt arithmetic, for n ≤ 170.
  • Digit count — how many digits the result has (useful when the number is too big to scan).
  • Scientific approximation — the result in m × 10ᵉ form, always shown alongside the exact value.
  • Larger n (171–1000) — scientific notation only, since the exact result would be unreadable.
  • Worked examples — 0!, 5!, 10!, 13!, 20!, 52! load with one click.

One input, four pieces of information. The simplest formula in mathematics, with the wildest growth.