cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A340612 #15 Jan 15 2021 21:11:27
%S A340612 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 A340612 83,56,28,57,27,22,24,15,49,84,48,85,47,86,46,5,47,90,134,89,40,42,36,
%U A340612 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 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.
%C A340612 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 A340612 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 A340612 The smallest value not to have appeared after 1 million terms is 13. It is unknown if all terms eventually appear.
%H A340612 Scott R. Shannon, <a href="/A340612/a340612.png">Image of the first 1 million terms</a>.
%e A340612 a(3) = 2, as a(2) = 3 = n, thus a(3) = 2.
%e A340612 a(5) = 11, as 5 has not previously appeared in the sequence, but 1 has, a(5) = a(4) + 5 = 6 + 5 = 11.
%e A340612 a(11) = 7, as a(7) = 11 = n, thus a(11) = 7.
%o A340612 (Python)
%o A340612 def aupton(nn):
%o A340612   alst, index = [0], {0: 0} # data list, map of last occurrence
%o A340612   for n in range(1, nn+1):
%o A340612     if n in index:
%o A340612       an = index[n]
%o A340612     else:
%o A340612       an = alst[-1] - n
%o A340612       if an < 0 or an in index:
%o A340612         an = alst[-1] + n
%o A340612     alst.append(an)
%o A340612     index[an] = n
%o A340612   return alst
%o A340612 print(aupton(65)) # _Michael S. Branicky_, Jan 13 2021
%Y A340612 Cf. A005132, A340593, A339673, A336760, A336761.
%K A340612 nonn
%O A340612 0,3
%A A340612 _Scott R. Shannon_, Jan 13 2021