login
Number of (w,x,y,z) with all terms in {1,...,n} and w+|x-y|<=|x-z|+|y-z|.
2

%I #15 Aug 01 2015 10:27:37

%S 0,0,2,8,26,50,100,154,252,348,510,660,902,1118,1456,1750,2200,2584,

%T 3162,3648,4370,4970,5852,6578,7636,8500,9750,10764,12222,13398,15080,

%U 16430,18352,19888,22066,23800,26250,28194,30932,33098,36140

%N Number of (w,x,y,z) with all terms in {1,...,n} and w+|x-y|<=|x-z|+|y-z|.

%C Every term is even.

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

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

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

%F G.f.: 2*x^2*(1+3*x+6*x^2+x^4+3*x^3) / ( (1+x)^3*(x-1)^4 )

%F a(n) = n*(n-1)*(14*n-7+3*(-1)^n)/24. - _R. J. Mathar_, Jul 01 2013

%t t = Compile[{{n, _Integer}}, Module[{s = 0},

%t (Do[If[w + Abs[x - y] == Abs[x - z] + Abs[y - z],

%t s = s + 1],

%t {w, 1, #}, {x, 1, #}, {y, 1, #}, {z, 1, #}] &[n]; s)]];

%t Map[t[#] &, Range[0, 40]] (* A212691 *)

%t %/2 (* integers *)

%t LinearRecurrence[{1, 3, -3, -3, 3, 1, -1}, {0, 0, 2, 8, 26, 50, 100}, 40]

%Y Cf. A211795.

%K nonn,easy

%O 0,3

%A _Clark Kimberling_, May 25 2012