OFFSET
1,2
COMMENTS
Note that any such sequence has at least 2 balls, and at most n+1
Number of sequences of balls colored with at most n colors such that exactly two balls are the same color as some other ball in the sequence (necessarily each other). - Jeremy Dover, Sep 26 2017
LINKS
Jeremy Dover, Table of n, a(n) for n = 1..99
FORMULA
a(n) = n! * Sum_{k=2..n+1} binomial(k,2)/(n+1-k)!.
a(n) = n if n < 2, a(n) = n*((n+2)/(n-1)*a(n-1) - a(n-2)) for n >= 2. - Alois P. Heinz, Feb 02 2017
a(n)/n! ~ e*n^2/2. - Vaclav Kotesovec, Feb 03 2017
EXAMPLE
n=1 => AA -> a(1) = 1.
n=2 => AA,BB,AAB,ABA,BAA,BBA,BAB,ABB -> a(2) = 8.
MAPLE
a:= proc(n) option remember;
`if`(n<2, 1, a(n-1)*(n+2)/(n-1)-a(n-2))*n
end:
seq(a(n), n=1..25); # Alois P. Heinz, Feb 02 2017
MATHEMATICA
Table[n!*Sum[Binomial[k, 2]/(n + 1 - k)!, {k, 2, n + 1}], {n, 20}] (* Michael De Vlieger, Feb 02 2017 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Jeremy Dover, Feb 01 2017
STATUS
approved