Advanced Subfactorial Calculator

Explore exact derangements, recurrence values, and probability insights. Compare factorial growth using clean visual outputs. Export results quickly for classes, proofs, reports, and experiments.

Calculator Input

Use exact integer arithmetic for !n up to 500. The graph range is capped at 60 to keep the visual clear and fast.

Computes !n exactly using recurrence.
Start index for the table and graph.
End index for the table and graph.
Used for probability output formatting.
Log scale is better for large growth.

Example data table

These sample rows show common derangement results and how the probability approaches 1/e.

n n! !n P(no fixed points)
4 24 9 0.375000
5 120 44 0.366667
6 720 265 0.368056
7 5040 1854 0.367857
8 40320 14833 0.367882

Formula used

Definition: !n counts permutations of n items with no fixed points.
Recurrence: !0 = 1, !1 = 0, and !n = (n - 1) × ( !(n - 1) + !(n - 2) ).
Inclusion-exclusion: !n = n! × Σ[(-1)^k / k!] for k from 0 to n.
Approximation: !n ≈ n! / e, and for n > 0 the nearest integer to n! / e equals !n.
Probability form: P(no fixed points) = !n / n! = Σ[(-1)^k / k!] from 0 to n.

This calculator computes the exact integer subfactorial through recurrence, then derives factorial comparison values, fixed-point counts, probability estimates, scientific notation, and graph data.

How to use this calculator

  1. Enter a nonnegative integer n for the derangement count.
  2. Choose the table and graph range you want to inspect.
  3. Select decimal precision for probability values.
  4. Pick log scale for magnitude comparison or linear scale for approximate growth.
  5. Press the calculate button to show results above the form.
  6. Review exact values, sequence rows, and the Plotly graph.
  7. Use the CSV or PDF buttons to export your result set.

FAQs

1. What is a subfactorial?

A subfactorial counts permutations where no item remains in its original position. In combinatorics, this is also called the derangement number.

2. Why is subfactorial written as !n?

The symbol !n is a standard shorthand for the derangement count. It looks like factorial notation, but it represents a different combinatorial function.

3. Why does the value approach n!/e?

Inclusion-exclusion produces an alternating series that converges to 1/e after division by n!. That makes !n very close to n!/e for moderate and large n.

4. Why are !0 and !1 special cases?

For zero objects, there is exactly one empty permutation, so !0 = 1. For one object, the item cannot move away from itself, so !1 = 0.

5. What does the probability result mean?

It is the chance that a random permutation of n objects has no fixed points. This equals !n divided by n! and approaches 1/e.

6. Why is log scale useful in the graph?

Factorials and subfactorials grow extremely fast. Log scale compresses that growth so both curves remain readable and comparable over a wider range.

7. Can this calculator handle large n?

Yes. Exact integer values are computed with string-based arithmetic up to the page limit. The graph range is capped separately to keep plotting responsive.

8. When would I use a subfactorial calculator?

Use it for derangement problems, combinatorics classes, matching restrictions, secret exchange puzzles, coding interviews, probability models, and proof verification tasks.

Related Calculators

probability combination calculatorbinomial coefficient calculatorpermutation with repetition calculatordouble factorial calculatorcombination with repetition calculatoranagram calculatorstirling number calculatorpartition number calculatorsubset sum calculatorsubset calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.