login
A287422
a(1) = a(2) = 1; a(n) = n - a(a(n-1)) - a(n-a(n-1)) for n > 2.
5
1, 1, 1, 2, 3, 4, 4, 4, 4, 4, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 13, 13, 14, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 19, 19, 19, 19, 20, 21, 21, 22, 22, 22, 23, 24, 25, 25, 26, 26, 27, 28, 29, 29, 30, 31, 32, 33, 34, 35, 36, 36, 37, 38, 39, 40, 40, 41, 42, 42, 42, 43, 44, 45, 46, 46
OFFSET
1,4
MATHEMATICA
Nest[Function[{a, n}, Append[a, n - a[[a[[-1]] ]] - a[[-a[[-1]] ]] ] ] @@ {#, Length@ # + 1} &, {1, 1}, 80] (* Michael De Vlieger, Aug 07 2018 *)
PROG
(PARI) q=vector(10000); q[1]=q[2]=1; for(n=3, #q, q[n]=n-q[q[n-1]]-q[n-q[n-1]]); q
(Magma) I:=[1, 1, 1, 2]; [n le 4 select I[n] else n - Self(Self(n-1)) - Self(n-Self(n-1)): n in [1..100]]; // Vincenzo Librandi, Aug 08 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
Altug Alkan, Jun 24 2017
STATUS
approved