A000959 Lucky numbers.
1, 3, 7, 9, 13, 15, 21, 25, 31, 33, 37, 43, 49, 51, 63, 67, 69, 73, 75, 79, 87, 93, 99, 105, 111, 115, 127, 129, 133, 135, 141, 151, 159, 163, 169, 171, 189, 193, 195, 201, 205, 211, 219, 223, 231, 235, 237, 241, 259, 261, 267, 273, 283, 285, 289, 297, 303
Offset: 1
References
- Martin Gardner, Gardner's Workout, Chapter 21 "Lucky Numbers and 2187" pp. 149-156 A. K. Peters MA 2002.
- Richard K. Guy, Unsolved Problems in Number Theory, C3.
- C. S. Ogilvy, Tomorrow's Math. 2nd ed., Oxford Univ. Press, 1972, p. 99.
- N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
- N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
- M. L. Stein and P. R. Stein, Tables of the Number of Binary Decompositions of All Even Numbers Less Than 200,000 into Prime Numbers and Lucky Numbers. Report LA-3106, Los Alamos Scientific Laboratory of the University of California, Los Alamos, NM, Sep 1964.
- James J. Tattersall, Elementary Number Theory in Nine Chapters, Cambridge University Press, 1999, page 116.
- David Wells, The Penguin Dictionary of Curious and Interesting Numbers. Penguin Books, NY, 1986, 114.
Links
- Hugo van der Sanden, Table of n, a(n) for n = 1..200000 (terms 1..10000 from T. D. Noe, terms 10001..30981 from R. J. Mathar)
- José Juan Barco, Highly efficient C implementation with O(n log n) time and O(n) space (n bits) using hierarchical Fenwick trees and bitmaps to optimize memory access. Based on: J. Bille, I. Larsen, I. L. Gørtz et al., "Succinct Partial Sums and Fenwick Trees," ESA 2017.
- José Juan Barco, Very fast O(n log n) sequence generating program in Haskell
- H. M. Bui and J. P. Keating, On twin primes associated with the Hawkins random sieve, J. Number Theory 119(2) (2006), 284-296.
- H. M. Bui and J. P. Keating, On twin primes associated with the Hawkins random sieve, arXiv:math/0607196 [math.NT], 2006-2010.
- Vema Gardiner, R. Lazarus, N. Metropolis, and S. Ulam, On certain sequences of integers defined by sieves, Math. Mag., 29 (1956), 117-122. doi:10.2307/3029719; Zbl 0071.27002.
- Martin Gardner, Lucky numbers and 2187, Math. Intellig., 19(2) (1997), 26-29.
- David Hawkins, The random sieve, Math. Mag. 31 (1958), 1-3.
- D. Hawkins and W. E. Briggs, The lucky number theorem, Math. Mag. 31 (1958), 81-84.
- C. C. Heyde, A Log Log Improvement to the Riemann Hypothesis for the Hawkins Random Sieve, Ann. Probability, 6 (1978), 850-875.
- Ivars Peterson and MathTrek, Martin Gardner's Lucky Numbers (archived on Archive.org).
- Ivars Peterson, Martin Gardner's Lucky Numbers (archived on Wikiwix.com)
- Popular Computing (Calabasas, CA), Sieves: Problem 43, Vol. 2 (No. 13, Apr 1974), pp. 6-7. This is Sieve #7. [Annotated and scanned copy]
- Walter Schneider, Lucky Numbers, personal web site "Mathews: the Archive of Recreational Mathematics" (no more available: snapshot on web.archive.org as of May 2007), updated Dec 24, 2002.
- Torsten Sillke, S. M. Ulam's Lucky Numbers
- Hugo van der Sanden, Lucky numbers up to 1e8. [Broken link]
- G. Villemin's Almanach of Numbers, Nombre Chanceux.
- Eric Weisstein's World of Mathematics, Lucky number.
- Wikipedia, Lucky number.
- David W. Wilson, Fast space-efficient sequence generating program in C++.
- Index entries for "core" sequences
- Index entries for sequences related to lucky numbers
- Index entries for sequences generated by sieves [From _Reinhard Zumkeller_, Oct 15 2008]
Crossrefs
Programs
-
Haskell
a000959 n = a000959_list !! (n-1) a000959_list = 1 : sieve 2 [1,3..] where sieve k xs = z : sieve (k + 1) (lucky xs) where z = xs !! (k - 1 ) lucky ws = us ++ lucky vs where (us, _:vs) = splitAt (z - 1) ws -- Reinhard Zumkeller, Dec 05 2011
-
Haskell
-- Also see links. (C++) // See Wilson link, Nov 14 2012
-
Maple
## luckynumbers(n) returns all lucky numbers from 1 to n. ## Try n=10^5 just for fun. luckynumbers:=proc(n) local k, Lnext, Lprev; Lprev:=[$1..n]; for k from 1 do if k=1 or k=2 then Lnext:= map(w-> Lprev[w],remove(z -> z mod Lprev[2] = 0,[$1..nops(Lprev)])); if nops(Lnext)=nops(Lprev) then break fi; Lprev:=Lnext; else Lnext:= map(w-> Lprev[w],remove(z -> z mod Lprev[k] = 0,[$1..nops(Lprev)])); if nops(Lnext)=nops(Lprev) then break fi; Lprev:=Lnext; fi; od; return Lnext; end: # Walter Kehowski, Jun 05 2008; typo fixed by Robert Israel, Nov 19 2014 # Alternative A000959List := proc(mx) local i, L, n, r; L:= [seq(2*i+1, i=0..mx)]: for n from 2 while n < nops(L) do r:= L[n]; L:= subsop(seq(r*i=NULL, i=1..nops(L)/r), L); od: L end: A000959List(10^3); # Robert Israel, Nov 19 2014
-
Mathematica
luckies = 2*Range@200 - 1; f[n_] := Block[{k = luckies[[n]]}, luckies = Delete[luckies, Table[{k}, {k, k, Length@luckies, k}]]]; Do[f@n, {n, 2, 30}]; luckies (* Robert G. Wilson v, May 09 2006 *) sieveMax = 10^6; luckies = Range[1, sieveMax, 2]; sieve[n_] := Module[{k = luckies[[n]]}, luckies = Delete[luckies, Table[{i}, {i, k, Length[luckies], k}]]]; n = 1; While[luckies[[n]] < Length[luckies], n++; sieve[n]]; luckies L = Table[2*i + 1, {i, 0, 10^3}]; For[n = 2, n < Length[L], r = L[[n++]]; L = ReplacePart[L, Table[r*i -> Nothing, {i, 1, Length[L]/r}]]]; L (* Jean-François Alcover, Mar 15 2016, after Robert Israel *)
-
PARI
A000959_upto(nMax)={my(v=vectorsmall(nMax\2,k,2*k-1),i=1,q);while(v[i++]<=#v,v=vecextract(v,2^#v-1-(q=1<
M. F. Hasler, Sep 22 2013, improved Jan 20 2020 -
Python
def lucky(n): L = list(range(1, n + 1, 2)) j = 1 while j <= len(L) - 1 and L[j] <= len(L): del L[L[j]-1::L[j]] j += 1 return L # Robert FERREOL, Nov 19 2014, corrected by F. Chapoton, Mar 29 2020, performance improved by Ely Golden, Aug 18 2022
-
Scheme
(define (A000959 n) ((rowfun_n_for_A000959sieve n) n)) ;; Code for rowfun_n_for_A000959sieve given in A255543. ;; Antti Karttunen, Feb 26 2015
Formula
Start with the natural numbers. Delete every 2nd number, leaving 1 3 5 7 ...; the 2nd number remaining is 3, so delete every 3rd number, leaving 1 3 7 9 13 15 ...; now delete every 7th number, leaving 1 3 7 9 13 ...; now delete every 9th number; etc.
a(n) = A254967(n-1, n-1). - Reinhard Zumkeller, Feb 11 2015
a(n) = A258207(n,n). [Where A258207 is a square array constructed from the numbers remaining after each step described above.] - Antti Karttunen, Aug 06 2015
Other identities from Antti Karttunen, Feb 26 2015: (Start)
For all n >= 1, A109497(a(n)) = n.
Comments