Integer derangements count
integer-derangements-count · version 1.0.0 · Numbers & math · free, no key needed
Compute !n, the number of derangements (permutations with no fixed point) of n items, exactly.
Use when you need to: integer derangements count · subfactorial · permutations with no fixed points.
Supported
- integer derangements count
- subfactorial
- permutations with no fixed points
Not supported
- negative index
- partial derangements
- floating-point approximation
Behavior
- n is a JSON integer from 0 to 100000.
- !0 is 1 (the empty permutation) and !1 is 0 (a single item cannot avoid its own position).
- The sequence is computed via the exact integer recurrence !n = (n-1) * (!(n-1) + !(n-2)), never floating point.
- Requests whose exact result would exceed 1000 digits are rejected rather than truncated.
Input
n(integer, required): min 0; max 100000
Output
value(string, required)
Limits
- max n: 100000
- max digits: 1000
Example
Request input:
{
"n": 4
}
Response:
{
"result": {
"value": "9"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "integer-derangements-count",
"version": "1.0.0",
"input": {
"n": 4
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/integer-derangements-count/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"n":4}'
The machine-readable contract is at /v1/tools/integer-derangements-count/versions/1.0.0.
CLI
node cli.mjs run integer-derangements-count 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Integer permutations count: Compute the exact number of k-permutations of n distinct items, P(n, k) = n! / (n-k)!.
- Integer binomial coefficient: Compute the exact binomial coefficient C(n, k), the number of ways to choose k items from n.
- Integer divmod: Integer quotient and remainder truncated toward zero.
- Integer totient: Compute Euler's totient function: the count of integers in [1, value] coprime to value.
- Array integer adjacent diff: Replace an array of canonical integer strings with consecutive first differences.
- Array integer clamp: Clamp an array of canonical integer strings to optional inclusive min and max bounds.