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.
%I A340593 #27 Jun 29 2023 10:59:51 %S A340593 0,1,3,5,9,6,11,4,12,8,18,24,16,29,15,29,17,33,23,42,22,43,63,45,34, %T A340593 59,85,58,30,45,73,104,72,55,31,66,102,65,27,66,26,67,48,69,25,54,100, %U A340593 53,95,46,96,147,199,152,107,74,130,187,160,135,75,14,76,98,162,125,86,127,195,238,168,97 %N A340593 a(0) = 0; for n > 0, if n appears in the sequence then a(n) = a(n-1) - lastindex(n) if nonnegative and not already in the sequence, otherwise a(n) = a(n-1) + 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 A340593 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 the step size from a(n-1) is set to lastindex(n), where lastindex(n) is the sequence index of the last appearance of n. %C A340593 The smallest value not to have appeared after 1 million terms is 52. It is unknown if all terms eventually appear. %e A340593 a(3) = 5 as a(2) = 3 = n, thus the step size from a(2) is 2. As 1 has previously appeared a(3) = a(2) + 2 = 3 + 2 = 5. %e A340593 a(5) = 6 as a(3) = 5 = n, thus the step size from a(4) is 3. As 6 has not previously appeared a(5) = a(4) - 3 = 9 - 3 = 6. %o A340593 (Python) %o A340593 from itertools import count, islice %o A340593 def A340593_gen(): # generator of terms %o A340593 a, ndict = 0, {0:0} %o A340593 yield 0 %o A340593 for n in count(1): %o A340593 yield (a:= (a-m if a>=(m:=ndict[n]) and a-m not in ndict else a+m) if n in ndict else (a-n if a>=n and a-n not in ndict else a+n)) %o A340593 ndict[a] = n %o A340593 A340593_list = list(islice(A340593_gen(),30)) # _Chai Wah Wu_, Jun 29 2023 %Y A340593 Cf. A005132, A339673, A340612, A336760, A336761. %K A340593 nonn %O A340593 0,3 %A A340593 _Scott R. Shannon_, Jan 13 2021