login
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