Algorithm-Combinatorics

 view release on metacpan or  search on metacpan

Combinatorics.pm  view on Meta::CPAN


        n! = 1,                      if 0 <= n <= 1
    (n-1)! = (n-1)*(n-2)*...*1,      if n > 1

See a few numbers in a comment of L<http://www.research.att.com/~njas/sequences/A000142>.


=head2 derangements(\@data)

The derangements of C<@data> are those reorderings that have no element
in its original place. In jargon those are the permutations of C<@data>
with no fixed points. For example, the derangements of C<@data = (1, 2,
3)> are:

    (2, 3, 1)
    (3, 1, 2)

The number of derangements of C<n> elements is:

    d(n) = 1,                       if n = 0
    d(n) = n*d(n-1) + (-1)**n,      if n > 0

README  view on Meta::CPAN


            n! = 1,                      if 0 <= n <= 1
        (n-1)! = (n-1)*(n-2)*...*1,      if n > 1

    See a few numbers in a comment of
    http://www.research.att.com/~njas/sequences/A000142.

  derangements(\@data)

    The derangements of `@data' are those reorderings that have no element
    in its original place. In jargon those are the permutations of `@data'
    with no fixed points. For example, the derangements of `@data = (1, 2,
    3)' are:

        (2, 3, 1)
        (3, 1, 2)

    The number of derangements of `n' elements is:

        d(n) = 1,                       if n = 0
        d(n) = n*d(n-1) + (-1)**n,      if n > 0



( run in 0.275 second using v1.01-cache-2.11-cpan-1c8d708658b )