login
Relative of Hofstadter Q-sequence: a(-310) = 4, a(-309) = 311, a(-308) = 4, a(-307) = 311; thereafter a(n) = a(n-a(n-1)) + a(n-a(n-2)).
5

%I #16 May 26 2026 10:03:00

%S 315,4,311,315,8,315,315,622,4,315,319,622,4,315,323,622,4,315,327,

%T 622,4,315,331,622,4,315,335,622,4,315,339,622,4,315,343,622,4,315,

%U 347,622,4,315,351,622,4,315,355,622,4,315,359,622,4,315,363,622,4,315,367,622

%N Relative of Hofstadter Q-sequence: a(-310) = 4, a(-309) = 311, a(-308) = 4, a(-307) = 311; thereafter a(n) = a(n-a(n-1)) + a(n-a(n-2)).

%C In calculating terms of this sequence, use the convention that a(n)=0 for n<=-311.

%C Sequences like this are more naturally considered with the first nonzero term in position 1. But this sequence would then begin with 311 terms consisting entirely of alternating 4's and 311's.

%C This sequence has exactly 658 terms, since a(658)=0 and computing a(659) would refer to itself.

%C a(n) = 2*a(n-4) - a(n-8) for 13 < n <= 312 and for 332 < n <= 623. - _Chai Wah Wu_, Jul 26 2020

%H Nathan Fox, <a href="/A283901/b283901.txt">Table of n, a(n) for n = 1..658</a>

%p A283901:=proc(n) option remember: if n <= -311 then 0: elif n = -310 then 4: elif n = -309 then 311: elif n = -308 then 4: elif n = -307 then 311: else A283901(n-A283901(n-1)) + A283901(n-A283901(n-2)): fi: end:

%t A283901[n_] := A283901[n] = Which[n <= -311, 0, n == -310 || n == -308, 4, n == -309 || n == -307, 311, True, A283901[n - A283901[n-1]] + A283901[n - A283901[n-2]]];

%t Array[A283901, 100] (* _Paolo Xausa_, May 26 2026 *)

%Y Cf. A005185, A283898, A283899, A283900, A283902.

%K nonn,fini,full,changed

%O 1,1

%A _Nathan Fox_, Mar 19 2017