login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

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
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
FORMULA
a(A000959(n)) = 1, a(A050505(n)) = 0.
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
Cf. A000959 (lucky numbers), A050505 (complement: unlucky numbers).
See also A010051, A192490.
Sequence in context: A015605 A015437 A015101 * A016340 A014021 A015725
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, Oct 15 2008
STATUS
approved