OFFSET
0,3
COMMENTS
This sequences uses the same rules as Recamán's sequence A005132 if the value of n itself has not previously appeared in the sequence. However if n has previously appeared then a(n) = lastindex(n), where lastindex(n) is the sequence index of the last appearance of n.
The terms appear to be clustered in bands which are themselves composed of thinner bands. No values appear outside these groupings. See the linked image.
The smallest value not to have appeared after 1 million terms is 13. It is unknown if all terms eventually appear.
LINKS
Scott R. Shannon, Image of the first 1 million terms.
EXAMPLE
a(3) = 2, as a(2) = 3 = n, thus a(3) = 2.
a(5) = 11, as 5 has not previously appeared in the sequence, but 1 has, a(5) = a(4) + 5 = 6 + 5 = 11.
a(11) = 7, as a(7) = 11 = n, thus a(11) = 7.
PROG
(Python)
def aupton(nn):
alst, index = [0], {0: 0} # data list, map of last occurrence
for n in range(1, nn+1):
if n in index:
an = index[n]
else:
an = alst[-1] - n
if an < 0 or an in index:
an = alst[-1] + n
alst.append(an)
index[an] = n
return alst
print(aupton(65)) # Michael S. Branicky, Jan 13 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Scott R. Shannon, Jan 13 2021
STATUS
approved