

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.


2



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
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

0,6


COMMENTS

For n > 2, a(n+1) is either the index or repeat of an earlier term (see Name). Hence terms are referred to here as being "index" or "repeat" respectively. Starting from a(3)=1, index and repeat terms occur alternatively throughout the sequence.
a(n) < n for all n >= 0. For k >= 2, numbers 0,1,...,2^k2 occur as terms in the interval between a(2^k2) = 0 and a(2^(k+1)2) = 0; see Formula (e.g., k = 2 > 0,1,2 occur between a(2) and a(6); k = 3 > 0,1,..,6 occur between a(6) and a(14)). Thus every integer >= 0 occurs infinitely many times in the sequence.
There appears to be a proper copy subsequence given by a(4*m+2) = a(m1); m >0 (noticed by Carl J Love). There may be other (independent) copies to be found (e.g. by selecting terms sequentially, one from each of the above mentioned intervals). A family of sequences similar to this one can be described using the same rule as above, with offset k >= 0 and initial terms a(k) = a(k+1) = k. Conjecture: Every such sequence contains a proper copy of itself as a(4*m+2+k) = a(m+k1).
Index terms > 0 are 1,2,4,3,6,5,10,9,8,7,14,13,... (see A132666). Repeat terms from a(4)=0 are 0,0,1,0,2,0,3,1,4,0,5,2,6,0,7,... (union of the nonnegative integers interleaved with the copy subsequence described above).
For any n >= 0, a k >= 0 exists such that a^k(n)=0 (e.g., n=5 > k=2; a^2(5)=0).
Replacing a(a(n)1) with a(a(n)+1) in the Name produces A025480 with 0 prepended.


LINKS

Rémy Sigrist, Table of n, a(n) for n = 0..10000


FORMULA

Conjectured formulae:
a(2^k2)=0 = a(3*2^k2) = 0; (k>=0).
a(5*2^k2) = 1, a(7*2^k2) = 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) = A32666(k); k >= 1.
a(4*k) = k1; k >= 1.
1stlevel copy subsequence: a(k1) = a(4*k+2), k >= 1.
(mth)level (dependent) copy subsequence: a(k) = a(4^m*(k+2)  2), m >= 1, k >= 0.


EXAMPLE

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.


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(n1), r:= `if`(used[p] > 1, pos[p], thisproc(p1));
(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);


CROSSREFS

Cf. A132666, A025480.
Sequence in context: A300252 A305796 A020781 * A007432 A079124 A242071
Adjacent sequences: A327880 A327881 A327882 * A327884 A327885 A327886


KEYWORD

nonn


AUTHOR

David James Sycamore, Oct 10 2019


STATUS

approved



