Calculators

Derangement Calculator

Calculate exact derangement counts for 0 to 1000 distinct items privately in your browser, with the formula and digit count.

Count permutations of distinct items where no item stays in its original position. Exact BigInt arithmetic keeps every digit. Your data stays in your browser.

Enter a whole number from 0 to 1000 using digits only. Zero items has one empty arrangement. Four items has nine derangements.

Your derangement count will appear here.

Count arrangements with no fixed positions.

A derangement is a permutation of distinct items in which no item remains in its original position. The count is also called the subfactorial, written !n or D(n). Use D(0) = 1 and D(1) = 0, then D(n) = (n − 1) × (D(n − 1) + D(n − 2)) for n ≥ 2. The counts for n = 0 through 5 are 1, 0, 1, 2, 9 and 44. For four items, D(4) = 3 × (2 + 1) = 9. Zero items has one empty arrangement; one item cannot move to a different position. This counts arrangements of distinct items with only the no-fixed-position restriction; it does not model repeated items or additional pairing restrictions. Enter 0 to 1000 using one to four digits. Leading zeros and surrounding whitespace are accepted; signs, decimals, separators and scientific notation are rejected. Exact BigInt arithmetic preserves every digit, and zero counts as one digit. All processing stays in your browser.

Frequently Asked Questions

Everything you need to know about this tool, how it works, and privacy.

What does a derangement count?

It counts permutations of distinct items where every item moves away from its original position. For example, four distinct items have nine derangements.

Why is D(0) equal to 1?

There is one arrangement of zero items: the empty arrangement. It has no fixed positions. D(1) is zero because a single item has nowhere else to go.

Is subfactorial the same as factorial?

No. Factorial n! counts all permutations, while subfactorial !n counts only those without fixed positions. For four items, 4! = 24 and !4 = 9.

Are the results exact and private?

Yes. Browser BigInt arithmetic calculates exact counts for 0 to 1000 items. No input is uploaded or stored. The result includes the decimal digit count; zero has one digit.