login

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

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

%I #5 Sep 20 2024 05:48:12

%S 0,0,2,3,0,5,0,7,0,0,0,11,2,3,0,5,0,7,0,19,0,0,2,3,0,5,0,7,0,29,0,31,

%T 2,3,0,5,0,7,0,0,0,41,2,3,0,5,0,7,0,0,0,0,2,3,0,5,0,7,0,59,0,61,2,3,0,

%U 5,0,7,0,0,0,71,2,3,0,5,0,7,0,79,0

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

%p mycat := (n, k) -> parse(cat(convert(n, string), convert(k, string))):

%p b10digs := n -> max(1, 1 + ilog10(n)): b10cat := (a, b) -> b + a * b10digs(b):

%p b10parts := p -> local j; [seq(irem(p, 10^(j+1)), j = 0..b10digs(p)-1)]:

%p b10primes := p -> local j; select(isprime, b10parts(p)):

%p b10maxprime := proc(n) max(b10primes(n)); ifelse(% = -infinity, 0, %) end: # A331097

%p b10minprime := proc(n) min(b10primes(n)); ifelse(% = infinity, 0, %) end:

%p seq(b10minprime(n), n = 0..80);

%Y Cf. A331097 (largest prime suffix).

%K nonn,base

%O 0,3

%A _Peter Luschny_, Sep 20 2024