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
Rémy Sigrist, Table of n, a(n) for n = 0..8192
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
KEYWORD
AUTHOR
Rémy Sigrist, Jan 09 2020
STATUS
approved