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.

A350579 The first number in A350578 to appear n times.

This page as a plain text file.
%I A350579 #15 Jan 09 2022 02:31:07
%S A350579 0,42,153,504,921,921,17729,17729,17729,17729,60610,60610,109617,
%T A350579 109617,109617,109617,109617,109617,109599,658778,658778,658778,
%U A350579 658778,658778,658778,658778,658778,658778,658778,658778,658778,658778,658778,658778,658778,2184074,2184074,2184074
%N A350579 The first number in A350578 to appear n times.
%C A350579 See A350578 for further details.
%H A350579 <a href="/index/Rea#Recaman">Index entries for sequences related to Recamán's sequence</a>
%e A350579 a(1) = 0 as A350578(0) = 0, thus 0 is the first number to appear one time.
%e A350579 a(2) = 42 as A350578(20) = A350578(24) = 42, thus 42 is the first number to appear two times. This is also true for A005132.
%e A350579 a(3) = 153 as A350578(74) = A350578(78) = A350578(114) = 153, thus 153 is the first number to appear three times.
%t A350579 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];
%t A350579 Table[k=0;While[Max[Last/@(c=Tally@Array[a,++k,0])]!=i];a[k-1],{i,6}] (* _Giorgos Kalogeropoulos_, Jan 07 2022 *)
%o A350579 (Python)
%o A350579 from itertools import count
%o A350579 from collections import Counter
%o A350579 def A350579(n):
%o A350579     b, bcounter = 0, Counter({0})
%o A350579     for m in count(1):
%o A350579         if bcounter[b] == n: return b
%o A350579         b += -m if b-m >= 0 and bcounter[b-m] <= bcounter[b+m] else m
%o A350579         bcounter[b] += 1 # _Chai Wah Wu_, Jan 08 2022
%Y A350579 Cf. A350578, A005132, A335299, A064389, A261573, A064387.
%K A350579 nonn
%O A350579 1,2
%A A350579 _Scott R. Shannon_, Jan 07 2022