OFFSET
1,1
COMMENTS
Is there an efficient formula for this sequence? To wit, is there an algorithm for determining whether n is a lucky or unlucky number which is substantially faster than determining the lucky numbers up to n? - Charles R Greathouse IV, Nov 24 2021
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..100005
Eric Weisstein's World of Mathematics, Lucky Numbers
MATHEMATICA
luckies = 2 Range[0, 100] + 1;
Module[{k, r}, For[k = 2, k<Length[luckies], r = luckies[[k++]]; luckies = ReplacePart[luckies, Table[r*i -> Nothing, {i, 1, Length[luckies]/r}]]]];
a[n_ /; 1 <= n <= Last[luckies]] := Boole[MemberQ[luckies, n]];
Table[a[n], {n, 1, Last[luckies]}] (* Jean-François Alcover, Oct 18 2021, after Robert Israel in A000959 *)
PROG
(PARI) A145649list(up_to) = { my(u=A000959_upto(up_to), v=vector(up_to)); for(i=1, #u, v[u[i]] = 1); (v); }; \\ See there for A000959_upto(). - Antti Karttunen, Sep 27 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, Oct 15 2008
STATUS
approved