This site is supported by donations to The OEIS Foundation.
Template:Arrangements/doc
From OeisWiki
arrangements}} mathematical function template returns the number of arrangements of
otherwise returns an error message.
otherwise returns an error message.
of
Examples with valid argument
and
rounded to nearest integer yields
, for
, where
and
are the number of arrangements and the number of derangements of
, respectively.
Examples with valid, but out of range, argument
, otherwise results seem to agree.
The {{n, 0 ≤ n ≤ 12, |
Usage
- {{arrangements|a nonnegative integer}}
or (by analogy with subfactorial, i.e. number of derangements: unfortunately the term superfactorial[1] has another meaning)
{{superfactorial|a nonnegative integer}}
or (by analogy with subfactorial, i.e. number of derangements: unfortunately the term superfactorial[1] has another meaning)
{{superfact|a nonnegative integer}}
Valid arguments
Returns the number of arrangements for a nonnegative integern, 0 ≤ n ≤ 12, |
Examples
A000522 The number of arrangementsan |
n, n ≥ 0. |
- {1, 2, 5, 16, 65, 326, 1957, 13700, 109601, 986410, 9864101, 108505112, 1302061345, 16926797486, 236975164805, 3554627472076, 56874039553217, 966858672404690, ...}
Examples with valid argument n, 0 ≤ n ≤ 12,
(returns the number of arrangements)
Code Result {{arrangements|0}} 1 {{arrangements|1}} 2 {{arrangements|2}} 5 {{arrangements|3}} 16 {{arrangements|4}} 65 {{arrangements|5}} 326 {{arrangements|6}} 1957 {{arrangements|7}} 13700 {{arrangements|8}} 109601 {{arrangements|9}} 986410 {{arrangements|10}} 9864101 {{arrangements|11}} 108505112 {{arrangements|12}} 1302061345
an |
dn |
n! |
n ≥ 2 |
an |
dn |
n |
Code Result Code Result {{root| {{arrangements|0}} * {{derangements|0}} }} √ 1 * 1{{n!|0}} 1 {{root| {{arrangements|1}} * {{derangements|1}} }} √ 2 * 0{{n!|1}} 1 {{root| {{arrangements|2}} * {{derangements|2}} }} √ 5 * 1{{n!|2}} 2 {{root| {{arrangements|3}} * {{derangements|3}} }} √ 16 * 2{{n!|3}} 6 {{root| {{arrangements|4}} * {{derangements|4}} }} √ 65 * 9{{n!|4}} 24 {{root| {{arrangements|5}} * {{derangements|5}} }} √ 326 * 44{{n!|5}} 120 {{root| {{arrangements|6}} * {{derangements|6}} }} √ 1957 * 265{{n!|6}} 720 {{root| {{arrangements|7}} * {{derangements|7}} }} √ 13700 * 1854{{n!|7}} 5040 {{root| {{arrangements|8}} * {{derangements|8}} }} √ 109601 * 14833{{n!|8}} 40320 {{root| {{arrangements|9}} * {{derangements|9}} }} √ 986410 * 133496{{n!|9}} 362880
Examples with valid, but out of range, argument n ≥ 13
(returns a not so user friendly error message)
Code Result {{arrangements|13}} 16926797486 {{arrangements|14}} 236975164805 {{arrangements|15}} 3554627472076 {{arrangements|16}} 56874039553217 {{arrangements|80}} 7.1526377254407E+35
Examples with invalid argument (returns a user friendly error message)
Code Result {{arrangements|-1}} Arrangements error: Argument must be a nonnegative integer {{arrangements|0.5}} Arrangements error: Argument must be a nonnegative integer {{arrangements|text}} Arrangements error: Argument must be a nonnegative integer {{arrangements|6 blobs}} Arrangements error: Argument must be a nonnegative integer
Code
{{ifint| ( {{{1|empty}}} ) | {{#ifexpr: ( {{{1}}} ) >= 0 | {{#ifexpr: ( {{{1}}} ) = 0 | 1 | {{expr| floor ( {{~Pochhammer| 1 | ( {{{1}}} ) | 1 }} * e ) }} }} | {{error| Arrangements error: Argument must be a nonnegative integer}} }} | {{error| Arrangements error: Argument must be a nonnegative integer}} }}
Gotcha: using round instead of ceil
Using round instead of ceil gives 3 instead of 2 fora1 |
{{ifint| ( {{{1|empty}}} ) | {{#ifexpr: ( {{{1}}} ) >= 0 | {{#ifexpr: ( {{{1}}} ) = 0 | 1 | {{expr| ( {{~Pochhammer| 1 | ( {{{1}}} ) | 1 }} * e ) round 0 }} }} | {{error| Derangements error: Argument must be a nonnegative integer}} }} | {{error| Derangements error: Argument must be a nonnegative integer}} }}
Code for {{derangements}}
{{ifint| ( {{{1|empty}}} ) | {{#ifexpr: ( {{{1}}} ) >= 0 | {{#ifexpr: ( {{{1}}} ) = 0 | 1 | {{expr| ( {{~Pochhammer| 1 | ( {{{1}}} ) | 1 }} / e ) round 0 }} }} | {{error| Derangements error: Argument must be a nonnegative integer}} }} | {{error| Derangements error: Argument must be a nonnegative integer}} }}
Notes
- ↑ 1.0 1.1 Weisstein, Eric W., Superfactorial, from MathWorld—A Wolfram Web Resource.
See also
- {{factorial}} or {{n!}}
- {{rising factorial}} or {{risefact}} or {{Pochhammer}} or {{Poch}} or {{x^(n)}}
- {{falling factorial}} or {{fallfact}} or {{(x)_n}}
- {{derangements}} or {{subfactorial}} or {{subfact}} or {{!n}}
- {{arrangements}}