OFFSET
1,3
COMMENTS
This sequence hits every positive integer.
Let b(1) = b(2) = b(3) = 1; for n >= 4, b(n) = b(t(n)) + b(n-t(n)) where t = A004001. Observe the symmetric relation between this sequence (a(n)) and b(n) thanks to line plots of a(n)-n/2 and b(n)-n/2 in Links section.
LINKS
Altug Alkan, Table of n, a(n) for n = 1..65536
Altug Alkan, Line plot of a(n)-n/2 for n <= 2^17
Altug Alkan, Line plots of a(n)-n/2 and b(n)-n/2 for n <= 2^11
FORMULA
a(n+1) - a(n) = 0 or 1 for all n >= 1.
MAPLE
b:= proc(n) option remember; `if`(n<3, 1,
b(b(n-1)) +b(n-b(n-1)))
end:
a:= proc(n) option remember; `if`(n<3, 1,
a(b(n)) +a(n-b(n)))
end:
seq(a(n), n=1..100); # after Alois P. Heinz at A317686
MATHEMATICA
t[1] = 1; t[2] = 1; t[n_] := t[n] = t[t[n-1]] + t[n - t[n-1]];
a[1] = a[2] = 1; a[n_] := a[n] = a[t[n]] + a[n - t[n]];
Array[a, 100] (* Jean-François Alcover, Nov 01 2020 *)
PROG
(PARI) t=vector(99); t[1]=t[2]=1; for(n=3, #t, t[n] = t[t[n-1]]+t[n-t[n-1]]); a=vector(99); a[1]=a[2]=1; for(n=3, #a, a[n] = a[t[n]]+a[n-t[n]]); a
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Altug Alkan, Aug 02 2018
STATUS
approved