OFFSET
0,3
LINKS
Jim Singh and others, Fascinating periodic sequence pairs, Mersenne Forum thread, July 2018.
Index entries for linear recurrences with constant coefficients, signature (1,2,-2).
FORMULA
a(n) = a(n-1) + 2*a(n-2) - 2*a(n-3) for n>2, a(0)=1, a(1)=0, a(2)=3.
From Bruno Berselli, Jul 12 2018: (Start)
G.f.: (1 - x + x^2)/((1 - x)*(1 - 2*x^2)).
a(n) = 2*a(n-2) + 1 for n>1, a(0)=1, a(1)=0.
a(n) = (1 + (-1)^n)*(2^(n/2) - 2^((n-3)/2)) + 2^((n-1)/2) - 1.
Therefore: a(4*k) = 2*4^k - 1, a(4*k+1) = 4^k - 1, a(4*k+2) = 4^(k+1) - 1, a(4*k+3) = 2*4^k - 1. (End)
EXAMPLE
Let 1. The first four terms are 1, (1-1)/2 = 0, 2*1+1 = 3, 1.
Let 4*1+3 = 7. The next four terms are 7, (7-1)/2 = 3, 2*7+1 = 15, 7.
Let 4*7+3 = 31. The next four terms are 31, (31-1)/2 = 15, 2*31+1 = 63, 31; etc.
MAPLE
seq(coeff(series((1-x+x^2)/((1-x)*(1-2*x^2)), x, n+1), x, n), n=0..45); # Muniru A Asiru, Jul 14 2018
MATHEMATICA
CoefficientList[Series[(1 - x + x^2)/((1 - x) (1 - 2 x^2)), {x, 0, 42}], x] (* Michael De Vlieger, Jul 13 2018 *)
LinearRecurrence[{1, 2, -2}, {1, 0, 3}, 46] (* Robert G. Wilson v, Jul 21 2018 *)
PROG
(GAP) a:=[1, 0, 3];; for n in [4..45] do a[n]:=a[n-1]+2*a[n-2]-2*a[n-3]; od; a; # Muniru A Asiru, Jul 14 2018
CROSSREFS
KEYWORD
nonn,easy,less
AUTHOR
Jim Singh, Jul 12 2018
STATUS
approved