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 A350578 #27 Jan 09 2022 02:31:01 %S A350578 0,1,3,6,2,7,13,20,12,21,11,22,10,23,9,24,8,25,43,62,42,63,41,18,42, %T A350578 17,43,16,44,15,45,14,46,79,113,78,114,77,39,0,40,81,123,80,36,81,35, %U A350578 82,34,83,33,84,32,85,31,86,30,87,29,88,28,89,27,90,26,91,157,224,156,225,155,226,154,227 %N A350578 a(0) = 0; for n > 0, if a(n-1) - n >= 0 and a(n-1) - n has appeared the same or fewer times than a(n-1) + n, then a(n) = a(n-1) - n. Otherwise a(n) = a(n-1) + n. %C A350578 This sequence is similar to the Recamán sequence A005132 except that here the number chosen to step to, if a(n-1) - n is >= 0, is determined by which of the two possible numbers, a(n-1) - n or a(n-1) + n, has appeared the fewest times. If the number of times these numbers have appeared is the same then a(n) = a(n-1) - n. If a(n-1) - n is less than zero then a(n) = a(n-1) + n. %C A350578 The first term to differ from A005132 is a(39) = 0. See the examples below. In the first 10^8 terms the largest value is a(99928118) = 842174195, while the smallest number not to have appeared is 366. It is likely all numbers eventually appear although this is unknown. %C A350578 See the companion sequence A350579 for the first number to appear n times. %H A350578 Scott R. Shannon, <a href="/A350578/a350578.png">Image of the first 10^8 terms</a>. %H A350578 <a href="/index/Rea#Recaman">Index entries for sequences related to Recamán's sequence</a> %e A350578 a(3) = 6 as a(2) = 3 giving the two possible numbers for the next step as 0 or 6. But 0 has already appeared once while 6 has not yet appeared, so 6 is chosen. %e A350578 a(39) = 0 as a(38) = 39 giving the two possible numbers for the next step as 0 or 78. Both 0 and 78 have already appeared once thus the smaller is chosen. This is the first term to differ from A005132. %e A350578 a(447) = 934 as a(446) = 487 giving the two possible numbers for the next step as 40 or 934. 40 has already appeared twice while 934 has appeared once, so the later is chosen. This is the first time both possible numbers have already appeared and the larger is chosen. %e A350578 a(2462) = 551 as a(2461) = 3013 giving the two possible numbers for the next step as 551 or 5475. 551 has already appeared once while 5475 has appeared twice, so the former is chosen. This is the first time both possible numbers have already appeared and the smaller is chosen. %t A350578 a[0]=0;a[n_]:=a[n]=If[a[n-1]-n>=0&&Count[Array[a,n-1,0],a[n-1]-n]<=Count[Array[a,n-1,0],a[n-1]+n],a[n-1]-n,a[n-1]+n];Array[a,74,0] (* _Giorgos Kalogeropoulos_, Jan 07 2022 *) %o A350578 (Python) %o A350578 from itertools import count, islice %o A350578 from collections import Counter %o A350578 def A350578_gen(): # generator of terms %o A350578 yield 0 %o A350578 b, bcounter = 0, Counter({0}) %o A350578 for n in count(1): %o A350578 b += -n if b-n >= 0 and bcounter[b-n] <= bcounter[b+n] else n %o A350578 bcounter[b] += 1 %o A350578 yield b %o A350578 A350578_list = list(islice(A350578_gen(),30)) # _Chai Wah Wu_, Jan 08 2022 %Y A350578 Cf. A005132, A350579, A335299, A064389, A261573, A064387. %K A350578 nonn %O A350578 0,3 %A A350578 _Scott R. Shannon_, Jan 07 2022