A254811 Number of ways to put n red, n blue, and n green balls into n indistinguishable boxes.
1, 1, 14, 171, 1975, 20096, 187921, 1609727, 12827392, 95701382, 673873648, 4503935052, 28728268655, 175644353402, 1033386471872, 5870110651051, 32289704469531, 172438417419444, 896076816466546, 4540173176769827, 22469530730320361
Offset: 0
Keywords
Examples
For n = 2 the a(2) = 14 ways to put 2 red balls, 2 blue balls, and 2 green balls into 2 indistinguishable boxes are (RRBBGG)(), (RRBBG)(G), (RRBGG)(B), (RBBGG)(R), (RRBB)(GG), (RRGG)(BB), (BBGG)(RR), (RRBG)(BG), (RBBG)(RG), (RBGG)(RB), (RRB)(BGG), (RBB)(RGG), (RRG)(BBG), (RGB)(RGB).
References
- D. A. Knuth, The Art of Computer Programming. Volume 4, Fascicle 3, Addison-Wesley, 2010, pp. 74 - 77.
Links
- Brian Chen, Table of n, a(n) for n = 0..64
Programs
-
Maple
with(numtheory): b:= proc(n, k, i) option remember; `if`(n>k, 0, 1) +`if`(isprime(n) or i<2, 0, add( `if`(d>k, 0, b(n/d, d, i-1)), d=divisors(n) minus {1, n})) end: a:= n-> b(30^n$2,n): seq(a(n), n=0..8); # Alois P. Heinz, Mar 26 2015
-
Mathematica
b[n_, k_, i_] := b[n, k, i] = If[n>k, 0, 1] + If[PrimeQ[n] || i<2, 0, Sum[ If[d>k, 0, b[n/d, d, i-1]], {d, Divisors[n][[2 ;; -2]]}]]; a[n_] := b[30^n, 30^n, n]; Table[a[n], {n, 0, 8}] (* Jean-François Alcover, Jan 08 2016, after Alois P. Heinz *)
Comments