OFFSET
1,2
COMMENTS
a(n) is the solution to the recurrence relation a(n) = a(n-a(n-1)) + a(n-a(n-2)) [Hofstadter's Q recurrence], with the initial conditions: a(n) = 0 if n <= 0; a(1) = 0, a(2) = 2, a(3) = 3, a(4) = 1.
LINKS
Nathan Fox, Table of n, a(n) for n = 1..10000
Index entries for linear recurrences with constant coefficients, signature (0, 0, 2, 0, 0, -1).
FORMULA
G.f.: (-x*(x^6 + x^5 + x^3 - x^2 - 3*x - 2)) / ((-1 + x)^2*(1 + x + x^2)^2).
a(n) = 2*a(n-3) - a(n-6) for n > 8.
a(1) = 0, a(2) = 2; thereafter a(3*k) = 3*k, a(3*k+1) = 1, a(3*k+2) = 3.
MAPLE
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Nathan Fox, Mar 19 2017
STATUS
approved