OFFSET
1,3
COMMENTS
A fifth-order recursion based on Hofstadter's Q-sequence A005185.
LINKS
Paolo P. Lava, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = a(a(a(a(n - a(n-1))))) + a(n - a(n-2)) with a(1) = a(2) = 1.
MATHEMATICA
Hofstadter1[1] = Hofstadter1[2] = 1; Hofstadter1[n_Integer?Positive] := Hofstadter1[n] = Hofstadter1[Hofstadter1[Hofstadter1[Hofstadter1[n - Hofstadter1[n - 1]]]]] + Hofstadter1[ n - Hofstadter1[n - 2]]; a = Table[Hofstadter1[n], {n, 1, digits}]
PROG
(Sage)
@CachedFunction
def a(n): return 1 if (n<3) else a(a(a(a(n -a(n-1))))) + a(n-a(n-2));
[a(n) for n in (1..90)] # G. C. Greubel, Sep 11 2021
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Roger L. Bagula, May 30 2005
STATUS
approved