A083747 Smallest number m >= 0 such that n followed by m ones yields a prime; a(p) = -1 if no such m exists.
1, 0, 0, 1, 0, 1, 0, 2, 2, 1, 0, 136, 0, 9, 1, 3, 0, 1, 0, 2, 1, 3, 0, 1, 1, 3, 1, 1, 0, 2, 0, 35, 1, 6, 2, 4, 0, -1, 2, 1, 0, 1, 0, 3, 772, 1, 0, 5, 1, 2, 4, 1, 0, 1, 31, 18470, 1, 3, 0, 1, 0, 2, 1, 1, 3, 1, 0, 3, 1, 1, 0, 2, 0, 2, 1, 1, 9, 4, 0, 2, 1, 1, 0, 5, 6, 3, 149, 1, 0, 2, 1, 3, 2, 1, 2, 7, 0, 2, 1, 10, 0, 1, 0, 44, 1, 1, 0, 5, 0, 17, 16, 3, 0, 2, 1, 9, 1, 1, 5, 1
Offset: 1
Examples
a(8) = 2 because 8 and 81 are composite but 811 is prime. From _M. F. Hasler_, Jun 05 2024: (Start) For n = 38, a(38) = -1 because the number 38 with m ones appended is divisible by 3 whenever m == 1 (mod 3) and by 37 for m == 2 (mod 3), and for m = 3k, k >= 0, it equals (x^3 - 1)/9 = (x - 1)/3 * (x^2 + x + 1)/3 with x = 7*10^k. For n = 176, a(176) = -1 because appending any number m of 1's will always yield a number divisible by 11 if m is even, by 3 if m == 1 (mod 3), by 7 if m == 5 (mod 6) or by 13 if m == 3 (mod 6). (End)
Links
- Toshitaka Suzuki, Table of n, a(n) for n = 1..602
- Jon Perry, Wilde Primes (backup on web.archive.org as of Feb. 2007, ceased to exist in 2007).
Crossrefs
Cf. A069568.
Programs
-
PARI
{ aop(n, stop=500) = for(c=0, stop, isprime(n) && return(c); n=n*10+1); -1 } \\ Return value -1 means that a(n) = -1 or a(n) > stop, the search limit given as 2nd optional parameter.
Extensions
Definition and PARI/GP code edited by M. F. Hasler, Jun 05 2024
Comments