OFFSET
1,1
COMMENTS
From Bernard Schott, Oct 22 2019: (Start)
Proposition:
For n >= 5, there exist terms a(n) <> -1 iff
* prime(n) is a prime repunit with m 1's and m is in A004023, then a(n) = 2, or
* prime(n) is a divisor of a semiprime repunit with m 1's and m is in A046413, then a(n) is the other prime factor of this semiprime.
Proof:
We must solve a(n) * prime(n) = repdigit = k * repunit, 1<= k <= 9, with a(n) least prime p that is solution.
According to the unicity of prime factorization, only two possibilities:
* prime(n) is repunit, then a(n) = k = 2 (smallest prime).
* prime(n) is not a repunit, then a(n) * prime(n) must be a repunit that is semiprime, then k = 1 and a(n) is the other factor of this semiprime.
Some examples:
Case 1: prime(n) is a repunit.
The first few values of m are 2, 19, 23, ...
If this repunit is the k-th prime, then a(k) = 2; it is the case for prime(5) = 11 with a(5) = 2 (see example).
Case 2: prime(n) is a divisor of repunit.
The first few values of m are 3, 4, 5, 7, 11, 17, 47, 59, 71, ...
For m = 3, 111 = 3 * 37.
As 37 = prime(12), a(12) = 3 with 3 * 37 = 111.
As 3 = prime(2) and a(2) = 2 < 37, 37 is not right here.
For m = 4, 1111 = 11 * 101.
As 101 = prime(26), a(26) = 11 with 11 * 101 = 11111.
As 11 = prime(5) and a(5) = 2 < 101, 101 is not right here.
For m = 5, 11111 = 41 * 271, so as prime(13) = 41 and prime(58) = 271, then a(13) = 271, and (58) = 41.
For m = 7, 1111111 = 239 * 4649, so a(52) = 4649 and a(628) = 239.
(End)
a(n) is positive for n in {1,2,3,4,5,12,13,26,52,58,628,2431,2968,42536,...}. - Ivan N. Ianakiev, Oct 26 2019
If n > 4, a(n) = 2 if A077573(n) = prime(n), A077573(n)/prime(n) if that is prime, otherwise -1. - Robert Israel, Nov 19 2019
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
Prime(5) is 11 and the least prime p such that all the digits of p*prime(5) are the same is 2 (as 2*11 = 22).
a(6) = -1 as repdigits are of the form k*(10^m - 1)/9, 1 <= k <= 9. We need the repdigit to be a semiprime of the form 13*p for some prime p. We need m = 6*t for some t >= 1. So (7*13) || (10^m - 1)/9, i.e., (10^m - 1)/9 can't be a semiprime and a(6) = -1. - David A. Corneth, Oct 16 2019
MAPLE
f:= proc(n) local o, p, q;
p:= ithprime(n);
o:= numtheory:-order(10, p);
q:= (10^o-1)/(9*p);
if isprime(q) then q elif q = 1 then 2 else -1 fi
end proc:
2, 2, 11, 11, seq(f(n), n=5..100); # Robert Israel, Nov 19 2019
MATHEMATICA
a[1]=a[2]=2; a[3]=a[4]=11; a[n_]:= Which[Union[IntegerDigits[Prime[n]]]=={1}, 2,
Module[{i=1}, While[!Divisible[(10^i-1), 9*Prime[n]], i++]; k=(10^i-1)/(9*Prime[n]);
PrimeQ[k]], k, True, -1]; a/@Range[85] (* Ivan N. Ianakiev, Oct 24 2019 *)
PROG
(PARI) a(n) = if(n<=5, return([2, 2, 11, 11, 2][n])); my(p=prime(n)); for(i=1, oo, if((10^i-1)/9%p==0, c=(10^i-1)/(9*p); if(isprime(c), return(c), return(-1)))) \\ David A. Corneth, Oct 22 2019
CROSSREFS
KEYWORD
sign,base
AUTHOR
Ivan N. Ianakiev, Oct 16 2019
EXTENSIONS
More terms from Bernard Schott and David A. Corneth, Oct 22 2019
STATUS
approved