cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A331097 a(n) is the greatest prime number of the form n mod (10^k) for some k > 0, or 0 if no such prime number exists.

Original entry on oeis.org

0, 0, 2, 3, 0, 5, 0, 7, 0, 0, 0, 11, 2, 13, 0, 5, 0, 17, 0, 19, 0, 0, 2, 23, 0, 5, 0, 7, 0, 29, 0, 31, 2, 3, 0, 5, 0, 37, 0, 0, 0, 41, 2, 43, 0, 5, 0, 47, 0, 0, 0, 0, 2, 53, 0, 5, 0, 7, 0, 59, 0, 61, 2, 3, 0, 5, 0, 67, 0, 0, 0, 71, 2, 73, 0, 5, 0, 7, 0, 79, 0
Offset: 0

Views

Author

Rémy Sigrist, Jan 09 2020

Keywords

Comments

In other words, a(n) is the largest prime suffix of n, or 0 if no such suffix exists.

Examples

			For n = 42:
- 42 mod (10^k) = 42 is not prime for k >= 2,
- 42 mod 10 = 2 is prime,
- hence a(42) = 2.
		

Crossrefs

Cf. A047814, A331044, A331102 (binary analog).

Programs

  • PARI
    a(n,base=10) = my (d=digits(n, base), s); for (k=1, #d, if (isprime(s=fromdigits(d[k..#d], base)), return (s))); 0

Formula

a(n) <= n with equality iff n = 0 or n is a prime number.