login
A287809
Number of septenary sequences of length n such that no two consecutive terms have distance 2.
0
1, 7, 39, 219, 1231, 6921, 38913, 218789, 1230147, 6916539, 38888455, 218651553, 1229375193, 6912200477, 38864063403, 218514412227, 1228604118319, 6907865088537, 38839687552689, 218377358251349, 1227833528067027, 6903532420748427, 38815326992539159
OFFSET
0,2
FORMULA
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.
G.f.: (1 + x - 3*x^2 - 2*x^3 + 2*x^4)/(1 - 6*x + 13*x^3 - 6*x^4).
EXAMPLE
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.
MATHEMATICA
LinearRecurrence[{6, 0, -13, 6}, {1, 7, 39, 219, 1231}, 40]
PROG
(Python)
def a(n):
.if n in [0, 1, 2, 3, 4]:
..return [1, 7, 39, 219, 1231][n]
.return 6*a(n-1)-13*a(n-3)+6*a(n-4)
KEYWORD
nonn,easy
AUTHOR
David Nacin, Jun 01 2017
STATUS
approved