login
A283878
An eventually quasilinear solution to Hofstadter's Q recurrence.
3
0, 2, 3, 1, 3, 6, 1, 3, 9, 1, 3, 12, 1, 3, 15, 1, 3, 18, 1, 3, 21, 1, 3, 24, 1, 3, 27, 1, 3, 30, 1, 3, 33, 1, 3, 36, 1, 3, 39, 1, 3, 42, 1, 3, 45, 1, 3, 48, 1, 3, 51, 1, 3, 54, 1, 3, 57, 1, 3, 60, 1, 3, 63, 1, 3, 66, 1, 3, 69, 1, 3, 72, 1, 3, 75
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.
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
A283878:=proc(n) option remember: if n <= 0 then 0: elif n = 1 then 0: elif n = 2 then 2: elif n = 3 then 3: elif n = 4 then 1: else A283878(n-A283878(n-1)) + A283878(n-A283878(n-2)): fi: end:
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Nathan Fox, Mar 19 2017
STATUS
approved