A090465 Smallest number m such that (n+1)*10^m-1 (i.e., n with m nines appended) yields a prime, or -1 if this will always yield a composite number.
1, 0, 0, 2, 0, -1, 0, 1, -1, 1, 0, -1, 0, 1, -1, 2, 0, -1, 0, 2, -1, 1, 0, -1, 3, 1, -1, 4, 0, -1, 0, 2, -1, 1, 1, -1, 0, 1, -1, 1, 0, -1, 0, 1, -1, 16, 0, -1, 1, 1, -1, 3, 0, -1, 5, 1, -1, 15, 0, -1, 0, 2, -1, 12, 1, -1, 0, 2, -1, 1, 0, -1, 0, 2, -1, 1, 3, -1, 0, 1, -1, 1, 0, -1, 1, 2, -1, 33, 0, -1, 1, 1, -1, 3, 10, -1, 0, 3, -1, 1, 0, -1, 0, 1, -1, 1, 0, -1
Offset: 1
Examples
a(25) = 3 because three 9's must be appended to 25 before a prime is formed (25999). a(6) = -1 because no matter how many 9's are appended to 6, the resulting number is always divisible by 3 and can therefore not be prime.
Links
- Toshitaka Suzuki, Table of n, a(n) for n = 1..4419
Crossrefs
Programs
-
Maple
f:= proc(n) local x,m; if n mod 3 = 0 and n <> 3 then return -1 fi; x:= n; for m from 0 to 10^4 do if isprime(x) then return m fi; x:= 10*x+9 od; fail end proc: map(f, [$1..200]); # Robert Israel, Jun 05 2024
-
PARI
apply( {A090465(n, LIM=500)=n%3 && for(m=0, LIM, ispseudoprime(n) && return(m); n=n*10+9); -(n>3)}, [1..55]) \\ Retun value -1 means that a(n) = -1 or, if n%3 > 0, then possibly a(n) > LIM, the search limit given as second (optional) parameter. - M. F. Hasler, Jun 05 2024
Formula
a(p) = 0 for p prime.
a(n) = -1 if n is a proper multiple of 3.
Extensions
Definition edited by M. F. Hasler, Jun 05 2024
Comments