login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A340612 a(0) = 0; for n > 0, if n appears in the sequence then a(n) = lastindex(n), where lastindex(n) is the index of the last appearance of n. Otherwise a(n) = a(n-1) - n if nonnegative and not already in the sequence, otherwise a(n) = a(n-1) + n. 8
0, 1, 3, 2, 6, 11, 4, 11, 19, 10, 9, 7, 19, 32, 18, 33, 17, 16, 14, 12, 32, 53, 31, 8, 32, 57, 83, 56, 28, 57, 27, 22, 24, 15, 49, 84, 48, 85, 47, 86, 46, 5, 47, 90, 134, 89, 40, 42, 36, 34, 84, 135, 187, 21, 75, 20, 27, 29, 87, 146, 206, 145, 207, 144, 80, 145, 79, 146, 78, 147, 77, 148, 76, 149 (list; graph; refs; listen; history; text; internal format)
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
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
Sequence in context: A331889 A369247 A367544 * A362373 A364929 A109876
KEYWORD
nonn
AUTHOR
Scott R. Shannon, Jan 13 2021
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 17 23:23 EDT 2024. Contains 371767 sequences. (Running on oeis4.)