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

%I #7 Aug 01 2015 10:24:51

%S 0,0,0,0,5,14,28,53,87,130,191,265,353,465,595,743,922,1123,1347,1608,

%T 1896,2211,2570,2960,3382,3854,4362,4906,5507,6148,6830,7575,8365,

%U 9200,10105,11059,12063,13143,14277,15465,16736,18065,19453,20930

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

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

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

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

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

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

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

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

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

%t LinearRecurrence[{1, 1, 1, -2, -2, 1, 1, 1, -1}, {0, 0, 0, 0, 5, 14, 28, 53, 87}, 40]

%Y Cf. A211795.

%K nonn,easy

%O 0,5

%A _Clark Kimberling_, May 23 2012