The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A140526 Number of derangements of n elements with one pair repeated exactly once (e.g., "ABABCDEF"). 0
 1, 4, 29, 230, 2033, 19744, 209581, 2418226, 30173825, 405194012, 5830108061, 89520810334, 1461569944369, 25288635875320, 462312939395693, 8905623605897834, 180313351427440001, 3828575562533760436 (list; graph; refs; listen; history; text; internal format)
 OFFSET 4,2 LINKS Hugo M. Spinelli, Program code related to this sequence FORMULA a(n) = ( (n^4 - 10*n^3 + 37*n^2 - 56*n + 25) * A000166(n-4) + (-1)^n * (-n^3 + 8*n^2 - 22*n + 19) ) / 4. - Max Alekseyev, Sep 22 2009 EXAMPLE a(4)=1 because "aabb" has only one derangement: "bbaa"; a(5)=4 because "aabbc" has four derangements: "bbaca", "bbcaa", "bcaab" and "cbaab". MATHEMATICA A000166[n_] := Floor[n!/E + 1/2]; a[4] = 1; a[n_] := ((n^4 - 10*n^3 + 37*n^2 - 56*n + 25)*A000166[n-4] + (-1)^n*(-n^3 + 8*n^2 - 22*n + 19))/4; Table[ a[n], {n, 4, 21}] (* Jean-François Alcover, Jan 30 2012, after Max Alekseyev *) CROSSREFS Cf. A105927 for derangements with an element repeated exactly once and no other repetition (e.g., "AABCDEF"); A105928 for derangements with an element appearing three times and no other repetition (e.g., "AAABCDEF"). Sequence in context: A079756 A221415 A087809 * A151343 A208812 A291103 Adjacent sequences:  A140523 A140524 A140525 * A140527 A140528 A140529 KEYWORD nonn,nice AUTHOR Hugo M. Spinelli (woodcroft(AT)poli.ufrj.br), Jul 02 2008, Jul 25 2008 EXTENSIONS Extended by Max Alekseyev, Sep 22 2009 STATUS approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified October 29 21:59 EDT 2020. Contains 338074 sequences. (Running on oeis4.)