A327883 a(0)=a(1)=0; thereafter a(n+1) is the index of the earliest as yet unused occurrence of a(n) if a(n) has occurred before; otherwise a(n+1) = a(a(n)-1). Once an occurrence of a(n) has been used it cannot be used again.
0, 0, 0, 1, 0, 2, 0, 4, 1, 3, 0, 6, 2, 5, 0, 10, 3, 9, 1, 8, 4, 7, 0, 14, 5, 13, 2, 12, 6, 11, 0, 22, 7, 21, 4, 20, 8, 19, 1, 18, 9, 17, 3, 16, 10, 15, 0, 30, 11, 29, 6, 28, 12, 27, 2, 26, 13, 25, 5, 24, 14, 23, 0, 46, 15, 45, 10, 44, 16, 43, 3, 42, 17, 41, 9, 40, 18, 39, 1, 38, 19, 37, 8
Offset: 0
Examples
a(2) = 0 since a(1) = 0 was last seen as a(0); a(3) = 1 since a(2) = 0 was last seen as a(1); a(4) = 0 since a(3) = 1 has not been seen before, so a(4) = a(a(3)-1) = a(0) = 0; a(327883)=163736.
Links
- Rémy Sigrist, Table of n, a(n) for n = 0..10000
- Michael De Vlieger, Log log scatterplot of a(n), n = 0..2^20, showing a(n) = 0 instead as 1/2 for visibility.
Programs
-
Maple
# Code by Carl J Love (via Mapleprimes). (This code is derived from Name. An alternative code (same author), based on a recursion deduced from empirical formulae (see above) produces identical output up to 100000 terms.) restart: a:= module() export pos:= table([0= 0]), nextpos:= table([0= 1]), used:= table(sparse, [0= 2]), ModuleApply:= proc(n::nonnegint) option remember; local p:= thisproc(n-1), r:= `if`(used[p] > 1, pos[p], thisproc(p-1)); (pos[r], used[r], nextpos[r]):= (nextpos[r], used[r]+1, n); r end proc; (ModuleApply(0), ModuleApply(1)):= (0,0) end module : seq(a(k), k= 0..100);
-
Mathematica
nn = 1000; c[] := 0; a[0] = a[1] = a[2] = 0; c[0] = 1; Do[If[# == 0, k = a[a[n - 1] - 1], k = #] &[c[a[n - 1]]]; Set[{a[n], c[a[n - 1]]}, {k, n - 1}], {n, 3, nn}]; Array[a, nn + 1, 0] (* _Michael De Vlieger, Jun 25 2025 *)
Formula
Conjectured formulae:
a(2^k-2)=0 = a(3*2^k-2) = 0; (k>=0).
a(5*2^k-2) = 1, a(7*2^k-2) = 2, (k>=0).
a(11*2^(2*k)-2) = a(9*2^(2*k+1)-2) = 3 (k>=0).
a(11*2^(2*k+1)-2) = a(9*2^(2k)-2) = 4 (k>=0).
a(2*k+1) = A132666(k); k >= 1.
a(4*k) = k-1; k >= 1.
1st-level copy subsequence: a(k-1) = a(4*k+2), k >= 1.
(m-th)-level (dependent) copy subsequence: a(k) = a(4^m*(k+2) - 2), m >= 1, k >= 0.
Comments