OFFSET
1,2
COMMENTS
The definition can obviously only be applied from k = a(2) = 2 on: for k = 1, all remaining numbers would be deleted. - M. F. Hasler, Nov 02 2024
REFERENCES
N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
LINKS
Donovan Johnson, Table of n, a(n) for n = 1..100000
David Applegate, C program for A003309.
Donovan Johnson, Ludic numbers computed up to A003309(1236290) = 23000711.
OEIS Wiki, Ludic numbers.
Popular Computing (Calabasas, CA), Sieves: Problem 43, Vol. 2 (No. 13, Apr 1974), pp. 6-7. This is Sieve #1. [Annotated and scanned copy]
Rosettacode Wiki, Ludic numbers.
FORMULA
From Antti Karttunen, Feb 23 2015: (Start)
(End)
MAPLE
ludic:= proc(N) local i, k, S, R;
S:= {$2..N};
R:= 1;
while nops(S) > 0 do
k:= S[1];
R:= R, k;
S:= subsop(seq(1+k*j=NULL, j=0..floor((nops(S)-1)/k)), S);
od:
[R];
end proc:
ludic(1000); # Robert Israel, Feb 23 2015
MATHEMATICA
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 *)
PROG
(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
(PARI) A3309=[1]; next_A003309(n)=n<A3309[#A3309] || until(, my(k=(#A3309-1)\2); forstep(j=#A3309-k, 2, -1, k+=1+k\(A3309[j]-1)); A3309=concat(A3309, k+2); k+2>n && break); n+!if(n=setsearch(A3309, n+1, 1), return(A3309[n])) \\ Should be made more efficient if n >> max(A3309). - M. F. Hasler, Nov 02 2024
{A003309(n) = while(n>#A3309, next_A003309(A3309[#A3309])); A3309[n]} \\ Should be made more efficient in case n >> #A3309. - M. F. Hasler, Nov 03 2024
(Haskell)
a003309 n = a003309_list !! (n - 1)
a003309_list = 1 : f [2..] :: [Int]
where f (x:xs) = x : f (map snd [(u, v) | (u, v) <- zip [1..] xs,
mod u x > 0])
-- Reinhard Zumkeller, Feb 10 2014, Jul 03 2011
(Scheme)
;; Antti Karttunen, Feb 23 2015
(Python)
remainders = [0]
ludics = [2]
N_MAX = 313
for i in range(3, N_MAX) :
ludic_index = 0
while ludic_index < len(ludics) :
ludic = ludics[ludic_index]
remainder = remainders[ludic_index]
remainders[ludic_index] = (remainder + 1) % ludic
if remainders[ludic_index] == 0 :
break
ludic_index += 1
if ludic_index == len(ludics) :
remainders.append(0)
ludics.append(i)
ludics = [1] + ludics
print(ludics)
# Alexandre Herrera, Aug 10 2023
def A003309(): # generator of the infinite list of ludic numbers
L = [2, 3]; yield 1; yield 2; yield 3
while k := len(L)//2: # could take min{k | k >= L[-1-k]-1}
for j in L[-1-k::-1]: k += 1 + k//(j-1)
L.append(k+2); yield k+2
# M. F. Hasler, Nov 02 2024
CROSSREFS
Cf. A192490 (characteristic function).
Cf. A192607 (complement).
Cf. A260723 (first differences).
Subsequence of A302036.
Cf. A237056, A237126, A237427, A235491, A255407, A255408, A255421, A255422, A260435, A260436, A260741, A260742 (permutations constructed from Ludic numbers).
KEYWORD
nonn,easy,nice
AUTHOR
EXTENSIONS
More terms from David Applegate and N. J. A. Sloane, Nov 23 2004
STATUS
approved