login
Number of (w,x,y,z) with all terms in {1,...,n} and median=mean.
9

%I #42 Jan 22 2024 10:43:15

%S 0,1,8,33,88,185,336,553,848,1233,1720,2321,3048,3913,4928,6105,7456,

%T 8993,10728,12673,14840,17241,19888,22793,25968,29425,33176,37233,

%U 41608,46313,51360,56761,62528,68673,75208,82145,89496,97273,105488,114153,123280

%N Number of (w,x,y,z) with all terms in {1,...,n} and median=mean.

%C For a guide to related sequences, see A211795.

%C For n>=1, a(n) is the number of cells in the n-th rhombic-dodecahedral polycube. - _George Sicherman_, Jan 22 2024

%H Reinhard Zumkeller, <a href="/A212133/b212133.txt">Table of n, a(n) for n = 0..10000</a>

%H <a href="/index/Rec#order_04">Index entries for linear recurrences with constant coefficients</a>, signature (4,-6,4,-1).

%F a(n) = 4*a(n-1) - 6*a(n-2) + 4*a(n-3) - a(n-4).

%F a(n) = n * (2*n^2 - 3*n + 2). - _J. M. Bergot_, Jun 22 2012

%F a(n) = A000384(n) + n*A000384(n-1). - _Bruno Berselli_, Jun 07 2013

%F a(n) = (A005917(n) + 1) / 2 for n > 0. - _Reinhard Zumkeller_, Nov 13 2014

%F G.f.: x*(1 + 4*x + 7*x^2) / (1 - x)^4. - _Colin Barker_, Dec 02 2017

%e a(2) counts these 4-tuples: (1,1,1,1), (1,1,2,2), (1,2,1,2), (2,1,1,2), (1,2,2,1), (2,1,2,1), (2,2,1,1), (2,2,2,2).

%t t = Compile[{{n, _Integer}},

%t Module[{s = 0}, (Do[If[Apply[Plus, Rest[Most[Sort[{w, x, y, z}]]]]/2 == (w + x + y + z)/4, s = s + 1], {w, 1, #}, {x, 1, #}, {y, 1, #}, {z, 1, #}] &[n]; s)]];

%t Flatten[Map[{t[#]} &, Range[0, 50]]] (* A212133 *)

%t (* _Peter J. C. Moses_, May 01 2012 *)

%o (PARI) a(n)=2*n^3-3*n^2+2*n; \\ _Joerg Arndt_, Jun 22 2012

%o (PARI) concat(0, Vec(x*(1 + 4*x + 7*x^2) / (1 - x)^4 + O(x^40))) \\ _Colin Barker_, Dec 02 2017

%o (Haskell)

%o a212133 n = if n == 0 then 0 else (a005917 n + 1) `div` 2

%o -- _Reinhard Zumkeller_, Nov 13 2014

%Y Cf. A211795.

%Y Cf. A226449. - _Bruno Berselli_, Jun 09 2013

%Y Cf. A005917.

%K nonn,easy

%O 0,3

%A _Clark Kimberling_, May 04 2012

%E Closed form adapted to the offset by _Bruno Berselli_, Jun 07 2013