%I #8 Jun 05 2017 16:03:28
%S 1,7,39,219,1231,6921,38913,218789,1230147,6916539,38888455,218651553,
%T 1229375193,6912200477,38864063403,218514412227,1228604118319,
%U 6907865088537,38839687552689,218377358251349,1227833528067027,6903532420748427,38815326992539159
%N Number of septenary sequences of length n such that no two consecutive terms have distance 2.
%H <a href="/index/Rec#order_04">Index entries for linear recurrences with constant coefficients</a>, signature (6, 0, -13, 6).
%F For n>4, a(n) = 6*a(n-1) - 13*a(n-3) + 6*a(n-4), a(1)=7, a(2)=39, a(3)=219, a(4)=1231.
%F G.f.: (1 + x - 3*x^2 - 2*x^3 + 2*x^4)/(1 - 6*x + 13*x^3 - 6*x^4).
%e For n=2 the a(2)=49-10=39 sequences contain every combination except these ten: 02,20,13,31,24,42,35,53,46,64.
%t LinearRecurrence[{6, 0, -13, 6}, {1, 7, 39, 219, 1231}, 40]
%o (Python)
%o def a(n):
%o .if n in [0, 1, 2, 3, 4]:
%o ..return [1, 7, 39, 219, 1231][n]
%o .return 6*a(n-1)-13*a(n-3)+6*a(n-4)
%Y Cf. A040000, A003945, A083318, A078057, A003946, A126358, A003946, A055099, A003947, A015448, A126473. A287804-A287819.
%K nonn,easy
%O 0,2
%A _David Nacin_, Jun 01 2017