login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A331102
a(n) is the greatest prime number of the form n mod (2^k) for some k > 0, or 0 if no such prime number exists.
2
0, 0, 2, 3, 0, 5, 2, 7, 0, 0, 2, 11, 0, 13, 2, 7, 0, 17, 2, 19, 0, 5, 2, 23, 0, 0, 2, 11, 0, 29, 2, 31, 0, 0, 2, 3, 0, 37, 2, 7, 0, 41, 2, 43, 0, 13, 2, 47, 0, 17, 2, 19, 0, 53, 2, 23, 0, 0, 2, 59, 0, 61, 2, 31, 0, 0, 2, 67, 0, 5, 2, 71, 0, 73, 2, 11, 0, 13, 2
OFFSET
0,3
COMMENTS
In other words, a(n) is the largest binary prime suffix of n, or 0 if no such suffix exists.
LINKS
FORMULA
a(n) <= n with equality iff n = 0 or n is a prime number.
EXAMPLE
For n = 45:
- we have:
k 45 mod (2^k) prime?
-- ------------ ------
1 1 no
2 1 no
3 5 yes
4 13 yes
5 13 yes
>5 45 no
- hence a(45) = 13.
PROG
(PARI) a(n, base=2) = my (d=digits(n, base), s); for (k=1, #d, if (isprime(s=fromdigits(d[k..#d], base)), return (s))); 0
CROSSREFS
Cf. A331097 (decimal analog).
Sequence in context: A339694 A074722 A370744 * A080368 A057174 A197658
KEYWORD
nonn,look,base
AUTHOR
Rémy Sigrist, Jan 09 2020
STATUS
approved