Is there prime number of the form $1+11+111+1111+11111+...$. I've checked it up to first 2000 repunits, but i found none. If $R_1=1$, $R_2=1+11$, $R_3=1+11+111$, $R_n=1+11+111+...+$nth repunit. What is the smallest n such that $R_n$ is prime ?
2026-02-23 06:40:32.1771828832
On
On
Primes from the sum of the first n repunits $1+11+111+1111+11111+...$
306 Views Asked by Armando T https://math.techqa.club/user/armando-t/detail At
3
There are 3 best solutions below
0
On
The first one is at $n=2497$, you just missed it!
Do[If[PrimeQ[(10^(n+1)-9n-10)/81], Print[n]], {n, 10^4}]
(* 2497 *)
(* 3301 *)
...
The direct formula for the $n^{\text{th}}$ term is from
Sum[10^j, {i, 0, n - 1}, {j, 0, i}]
(* 1/81 (-10 + 10^(1 + n) - 9 n) *)
0
On
To give some more examples of solutions, using Roman's direct formula for conciseness (alternately you can do something like r = 10*r+1; N += r in the loop).
Pari/GP (test is AES BPSW):
? for(n=1,6000,ispseudoprime((10^(n+1)-9*n-10)/81) && print(n))
2497
3301
time = 2min, 5,916 ms.
Perl/ntheory (v0.74) (test is ES BPSW):
$ time perl -Mntheory=:all -E 'is_prob_prime(divint(powint(10,$_+1)-9*$_-10,81)) and say for 1..6000;'
2497
3301
real 0m44.473s
PFGW (test is base 3 Fermat):
$ echo -e "ABC2 (10^(\$a+1)-9*\$a-10)/81\na: from 1 to 6000" > repsum.txt
$ time ./pfgw64 -k -u0 -f50 repsum.txt
(10^(2497+1)-9*2497-10)/81 is 3-PRP! (0.0793s+0.0362s)
(10^(3301+1)-9*3301-10)/81 is 3-PRP! (0.1333s+0.0615s)
real 0m42.963s
As the size gets larger, PFGW will get much faster relative to the others. E.g. times on Macbook Pro (2015) for checking n from 6001 to 7000 the times are 88.9s for Pari/GP, 26.0s for Perl/ntheory, and 13.4s for PFGW. Albeit for any discovered values we'd want to run another more strict test such as BPSW.
Here's the smallest such prime, found using this code:
$$1234567901234567901234567901234567901234567901234567901234567901234567 9012345679012345679012345679012345679012345679012345679012345679012345 6790123456790123456790123456790123456790123456790123456790123456790123 4567901234567901234567901234567901234567901234567901234567901234567901 2345679012345679012345679012345679012345679012345679012345679012345679 0123456790123456790123456790123456790123456790123456790123456790123456 7901234567901234567901234567901234567901234567901234567901234567901234 5679012345679012345679012345679012345679012345679012345679012345679012 3456790123456790123456790123456790123456790123456790123456790123456790 1234567901234567901234567901234567901234567901234567901234567901234567 9012345679012345679012345679012345679012345679012345679012345679012345 6790123456790123456790123456790123456790123456790123456790123456790123 4567901234567901234567901234567901234567901234567901234567901234567901 2345679012345679012345679012345679012345679012345679012345679012345679 0123456790123456790123456790123456790123456790123456790123456790123456 7901234567901234567901234567901234567901234567901234567901234567901234 5679012345679012345679012345679012345679012345679012345679012345679012 3456790123456790123456790123456790123456790123456790123456790123456790 1234567901234567901234567901234567901234567901234567901234567901234567 9012345679012345679012345679012345679012345679012345679012345679012345 6790123456790123456790123456790123456790123456790123456790123456790123 4567901234567901234567901234567901234567901234567901234567901234567901 2345679012345679012345679012345679012345679012345679012345679012345679 0123456790123456790123456790123456790123456790123456790123456790123456 7901234567901234567901234567901234567901234567901234567901234567901234 5679012345679012345679012345679012345679012345679012345679012345679012 3456790123456790123456790123456790123456790123456790123456790123456790 1234567901234567901234567901234567901234567901234567901234567901234567 9012345679012345679012345679012345679012345679012345679012345679012345 6790123456790123456790123456790123456790123456790123456790123456790123 4567901234567901234567901234567901234567901234567901234567901234567901 2345679012345679012345679012345679012345679012345679012345679012345679 0123456790123456790123456790123456790123456790123456790123456790123456 7901234567901234567901234567901234567901234567901234567901234567901234 5679012345679012345679012345679012345679012345679012345679012345679012 34567901234567901234567901234567901234567900957$$