OFFSET
1,12
COMMENTS
LINKS
Altug Alkan, Table of n, a(n) for n = 1..16384
Altug Alkan, Line plots of a(n) and A004074(n) for n <= 2^15
MAPLE
t:= proc(n) option remember; `if`(n<3, 1,
n -t(t(n-1)) -t(n-t(n-1)))
end:
b:= proc(n) option remember; `if`(n<3, 1,
b(t(n)) +b(n-t(n)))
end:
seq(2*b(n)-n, n=1..100); # after Alois P. Heinz at A317686
MATHEMATICA
Block[{t = NestWhile[Function[{a, n}, Append[a, n - a[[a[[-1]] ]] - a[[-a[[-1]] ]] ] ] @@ {#, Length@ # + 1} &, {1, 1}, Last@ # < 10^2 &], b}, b = NestWhile[Function[{b, n}, Append[b, b[[t[[n]] ]] + b[[-t[[n]] ]] ] ] @@ {#, Length@ # + 1} &, {1, 1}, Last@ # < Max@ t &]; Array[2 b[[#]] - # &, Length@ b] ] (* Michael De Vlieger, Aug 07 2018 *)
t[n_] := t[n] = If[n<3, 1, n - t[t[n-1]] - t[n - t[n-1]]]; b[n_] := b[n] = If[n<3, 1, b[t[n]] + b[n - t[n]]]; Table[2*b[n] - n, {n, 106}] (* Giovanni Resta, Aug 14 2018 *)
PROG
(PARI) t=vector(199); t[1]=t[2]=1; for(n=3, #t, t[n] = n-t[n-t[n-1]]-t[t[n-1]]); b=vector(199); b[1]=b[2]=1; for(n=3, #b, b[n] = b[t[n]]+b[n-t[n]]); vector(199, k, 2*b[k]-k)
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Altug Alkan, Aug 05 2018
STATUS
approved