%I M0655 #112 May 06 2024 08:45:27
%S 1,2,3,5,7,11,13,17,23,25,29,37,41,43,47,53,61,67,71,77,83,89,91,97,
%T 107,115,119,121,127,131,143,149,157,161,173,175,179,181,193,209,211,
%U 221,223,227,233,235,239,247,257,265,277,283,287,301,307,313
%N Ludic numbers: apply the same sieve as Eratosthenes, but cross off every k-th /remaining/ number.
%C Complement of A192607; A192490(a(n)) = 1. - _Reinhard Zumkeller_, Jul 05 2011
%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%H Donovan Johnson, <a href="/A003309/b003309.txt">Table of n, a(n) for n = 1..100000</a>
%H David Applegate, <a href="/A003309/a003309.txt">C program for A003309</a>.
%H Donovan Johnson, <a href="/A255420/a255420.txt">Ludic numbers computed up to A003309(1236290) = 23000711</a>.
%H OEIS Wiki, <a href="https://oeis.org/wiki/Ludic_numbers">Ludic numbers</a>.
%H Popular Computing (Calabasas, CA), <a href="/A003309/a003309.pdf">Sieves: Problem 43</a>, Vol. 2 (No. 13, Apr 1974), pp. 6-7. This is Sieve #1. [Annotated and scanned copy]
%H Rosettacode Wiki, <a href="http://rosettacode.org/wiki/Ludic_numbers">Ludic numbers</a>.
%H <a href="/index/Si#sieve">Index entries for sequences generated by sieves</a>
%F From _Antti Karttunen_, Feb 23 2015: (Start)
%F a(n) = A255407(A008578(n)).
%F a(n) = A008578(n) + A255324(n).
%F (End)
%p ludic:= proc(N) local i, k,S,R;
%p S:= {$2..N};
%p R:= 1;
%p while nops(S) > 0 do
%p k:= S[1];
%p R:= R,k;
%p S:= subsop(seq(1+k*j=NULL, j=0..floor((nops(S)-1)/k)),S);
%p od:
%p [R];
%p end proc:
%p ludic(1000); # _Robert Israel_, Feb 23 2015
%t t = Range[2, 400]; r = {1}; While[Length[t] > 0, k = First[t]; AppendTo[r, k]; t = Drop[t, {1, -1, k}];]; r (* _Ray Chandler_, Dec 02 2004 *)
%o (PARI) t=vector(399,x,x+1); r=[1]; while(length(t)>0, k=t[1];r=concat(r,[k]);t=vector((length(t)*(k-1))\k,x,t[(x*k+k-2)\(k-1)])); r \\ _Phil Carmody_, Feb 07 2007
%o (Haskell)
%o a003309 n = a003309_list !! (n - 1)
%o a003309_list = 1 : f [2..] :: [Int]
%o where f (x:xs) = x : f (map snd [(u, v) | (u, v) <- zip [1..] xs,
%o mod u x > 0])
%o -- _Reinhard Zumkeller_, Feb 10 2014, Jul 03 2011
%o (Scheme)
%o (define (A003309 n) (if (= 1 n) n (A255127bi (- n 1) 1))) ;; Code for A255127bi given in A255127.
%o ;; _Antti Karttunen_, Feb 23 2015
%o (Python)
%o remainders = [0]
%o ludics = [2]
%o N_MAX = 313
%o for i in range(3, N_MAX) :
%o ludic_index = 0
%o while ludic_index < len(ludics) :
%o ludic = ludics[ludic_index]
%o remainder = remainders[ludic_index]
%o remainders[ludic_index] = (remainder + 1) % ludic
%o if remainders[ludic_index] == 0 :
%o break
%o ludic_index += 1
%o if ludic_index == len(ludics) :
%o remainders.append(0)
%o ludics.append(i)
%o ludics = [1] + ludics
%o print(ludics)
%o # _Alexandre Herrera_, Aug 10 2023
%Y Without the initial 1 occurs as the leftmost column in arrays A255127 and A260717.
%Y Cf. A003310, A003311, A100464, A100585, A100586 (variants).
%Y Cf. A192503 (primes in sequence), A192504 (nonprimes), A192512 (number of terms <= n).
%Y Cf. A192490 (characteristic function).
%Y Cf. A192607 (complement).
%Y Cf. A260723 (first differences).
%Y Cf. A255420 (iterates of f(n) = A003309(n+1) starting from n=1).
%Y Subsequence of A302036.
%Y Cf. A237056, A237126, A237427, A235491, A255407, A255408, A255421, A255422, A260435, A260436, A260741, A260742 (permutations constructed from Ludic numbers).
%Y Cf. also A000959, A008578, A255324, A254100, A272565, A297158, A302032, A302038.
%K nonn,easy,nice
%O 1,2
%A _N. J. A. Sloane_
%E More terms from _David Applegate_ and _N. J. A. Sloane_, Nov 23 2004