login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Multilevel sieve: at k-th step, accept k numbers, reject k, accept k, ...
(Formerly M2792)
4

%I M2792 #47 Aug 07 2022 12:58:31

%S 1,3,9,25,57,145,337,793,1921,3849,8835,18889,41473,92305,203211,

%T 432699,944313,2027529,4077769,8745153,18133305,37898113,80713737,

%U 169730259,358760457,750591867,1575313473,3255787851,6751959507,14108682265,29364255033,61173205587

%N Multilevel sieve: at k-th step, accept k numbers, reject k, accept k, ...

%C Start with the natural numbers. For k=1,2,3,... successively do the following: accept k numbers, reject k numbers, accept k numbers, repeat indefinitely.

%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

%H N. J. A. Sloane, <a href="/A005209/b005209.txt">Table of n, a(n) for n = 1..1000</a> [Computed using Tom Duff's bc program]

%H Popular Computing (Calabasas, CA), <a href="/A005209/a005209.pdf">Contest 7 Results (based on solution from Tom Duff and Hugh Redelmeier)</a>, Vol. 4 (No. 43, Oct 1976), pp. 14-16. [Annotated scanned copy]

%H Jeffrey Shallit, <a href="/A001787/a001787.pdf">Letter to N. J. A. Sloane Mar 14, 1979, concerning A001787, A005209, A005210, A005211</a>

%H <a href="/index/Si#sieve">Index entries for sequences generated by sieves</a>

%o (bc)

%o for(k=1;k<=100;k++){

%o n=k;

%o for(i=k-1;i>=1;--i) n=2*n-((n-1)%i)-1;

%o print k, " ", n, "\n"

%o } /* _Tom Duff_, Apr 24 2015 */

%o (Python)

%o from itertools import count, islice

%o def agen(): # generator of terms

%o for k in count(1):

%o n = k

%o for i in range(k-1, 0, -1): n = 2*n-((n-1)%i)-1

%o yield n

%o print(list(islice(agen(), 32))) # _Michael S. Branicky_, Aug 06 2022 after _Tom Duff_

%K nonn

%O 1,2

%A _N. J. A. Sloane_