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

%I #15 Jan 15 2021 21:11:27

%S 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,

%T 83,56,28,57,27,22,24,15,49,84,48,85,47,86,46,5,47,90,134,89,40,42,36,

%U 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

%N 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.

%C 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.

%C 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.

%C The smallest value not to have appeared after 1 million terms is 13. It is unknown if all terms eventually appear.

%H Scott R. Shannon, <a href="/A340612/a340612.png">Image of the first 1 million terms</a>.

%e a(3) = 2, as a(2) = 3 = n, thus a(3) = 2.

%e a(5) = 11, as 5 has not previously appeared in the sequence, but 1 has, a(5) = a(4) + 5 = 6 + 5 = 11.

%e a(11) = 7, as a(7) = 11 = n, thus a(11) = 7.

%o (Python)

%o def aupton(nn):

%o alst, index = [0], {0: 0} # data list, map of last occurrence

%o for n in range(1, nn+1):

%o if n in index:

%o an = index[n]

%o else:

%o an = alst[-1] - n

%o if an < 0 or an in index:

%o an = alst[-1] + n

%o alst.append(an)

%o index[an] = n

%o return alst

%o print(aupton(65)) # _Michael S. Branicky_, Jan 13 2021

%Y Cf. A005132, A340593, A339673, A336760, A336761.

%K nonn

%O 0,3

%A _Scott R. Shannon_, Jan 13 2021

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 May 1 03:12 EDT 2024. Contains 372148 sequences. (Running on oeis4.)