OFFSET
1,1
COMMENTS
In calculating terms of this sequence, use the convention that a(n)=0 for n<=0.
Similar to Hofstadter's Q-sequence A005185 but with different starting values.
No other term of this sequence changes if a(4) is replaced by a number greater than 6.
If a(2) is replaced by a number N greater than 9, then every other term of the form a(5n+2) is replaced by a(5n+2)*N/9.
LINKS
Nathan Fox, Table of n, a(n) for n = 1..10000
FORMULA
MAPLE
MATHEMATICA
a[n_] := a[n] = Switch[n, _?NonPositive, 0, 1, 5, 2, 9, 3, 4, 4, 6, _,
a[n - a[n - 1]] + a[n - a[n - 2]]];
Table[a[n], {n, 1, 80}] (* Jean-François Alcover, Jul 24 2022 *)
PROG
(Python)
from functools import cache
@cache
def a(n):
if n < 0: return 0
if n < 5: return [0, 5, 9, 4, 6][n]
return a(n - a(n-1)) + a(n - a(n-2))
print([a(n) for n in range(1, 73)]) # Michael S. Branicky, Sep 20 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Nathan Fox, May 03 2016
STATUS
approved