|
|
A145649
|
|
Characteristic function of the lucky numbers.
|
|
17
|
|
|
1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
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
|
|
|
FORMULA
|
|
|
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]];
|
|
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
|
|
|
STATUS
|
approved
|
|
|
|