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.
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
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
- Enter a nonnegative integer n for the derangement count.
- Choose the table and graph range you want to inspect.
- Select decimal precision for probability values.
- Pick log scale for magnitude comparison or linear scale for approximate growth.
- Press the calculate button to show results above the form.
- Review exact values, sequence rows, and the Plotly graph.
- 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.