cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A034388 Smallest prime containing at least n consecutive identical digits.

This page as a plain text file.
%I A034388 #32 Jul 08 2025 20:19:17
%S A034388 2,11,1117,11113,111119,2999999,11111117,111111113,1777777777,
%T A034388 11111111113,311111111111,2111111111111,17777777777777,
%U A034388 222222222222227,1333333333333333,11111111111111119,222222222222222221,1111111111111111111,1111111111111111111
%N A034388 Smallest prime containing at least n consecutive identical digits.
%C A034388 For n in A004023, a(n) = A002275(n). For all other n > 1, a(n) has at least n+1 digits and is (for small n) often of the form a*10^n + b*(10^n-1)/9 or a*(10^n-1)/9*10 + b, with 1 <= a <= 9 and b in {1, 3, 7, 9}. However, for n = 24, 46, 48, 58, 60, 64, 66, ..., more digits are required. Only then a(n) can have a digit 0, and if it has, '0' is often the repeated digit. The first indices where a(n) has more than n+2 digits are n = 208, 277, 346, ... - _M. F. Hasler_, Feb 25 2016; corrected by _Robert Israel_, Feb 26 2016
%H A034388 M. F. Hasler and Robert Israel, <a href="/A034388/b034388.txt">Table of n, a(n) for n = 1..997</a> (1..200 from M. F. Hasler)
%H A034388 Chai Wah Wu, <a href="https://arxiv.org/abs/1805.07431">Can machine learning identify interesting mathematics? An exploration using empirically observed laws</a>, arXiv:1805.07431 [cs.LG], 2018.
%e A034388 a(1) = 2 because this is the smallest prime.
%e A034388 a(2) = 11 because this repunit with n=2 digits is prime.
%e A034388 a(3) = 1117 is the smallest prime with 3 repeated digits.
%e A034388 a(19) = (10^19-1)/9 = R(19) is again a repunit prime. Since all primes with 18 consecutive repeated digits have at least 19 digits, also a(18) = a(19). The same happens for a(22) = a(23).
%p A034388 f:= proc(n) local d, k,x,y,z,xs,ys,zs,c,cands;
%p A034388   for d from n do
%p A034388     cands:= NULL;
%p A034388     for k from 0 to d-n do
%p A034388       if k = 0 then zs:= [0] else zs:= [seq(i,i=1..10^k-1,2)] fi;
%p A034388       if d=n+k then xs:= [0]; ys:= [$1..9] else xs:= [$10^(d-k-n-1)..10^(d-k-n)-1]; ys:= [$0..9] fi;
%p A034388       cands:= cands, seq(seq(seq(z + 10^k*y*(10^n-1)/9 + x*10^(k+n), x = xs),y=ys),z=zs);
%p A034388     od;
%p A034388     cands:= sort([cands]);
%p A034388     for c in cands do if isprime(c) then return(c) fi od;
%p A034388   od
%p A034388 end proc:
%p A034388 map(f, [$1..30]); # _Robert Israel_, Feb 26 2016
%t A034388 With[{s = Length /@ Split@ IntegerDigits@ # & /@ Prime@ Range[10^6]}, Prime@ Array[FirstPosition[s, #][[1]] &, Max@ Flatten@ s]] (* _Michael De Vlieger_, Aug 15 2018 *)
%o A034388 (PARI) A034388(n)={for(d=0,9, my(L=[],k=0); for(a=0,10^d-1,a<10^k||k++; L=setunion(L,vector(10-!a,c,[a*10^n+10^n\9*(c-(a>0)),1])*10^(d-k)));for(i=1,#L,if(L[i][2]>1, L[i][1]+L[i][2]>L[i][1]=nextprime(L[i][1]),ispseudoprime(L[i][1]))&&return(L[i][1])))} \\ _M. F. Hasler_, Feb 28 2016
%Y A034388 Cf. A037053, A037055, A037057, A037059, A037061, A037063, A037065, A037067, A037069, A037071.
%Y A034388 Cf. A065821, A065586, A084673.
%K A034388 nonn,base
%O A034388 1,1
%A A034388 _Erich Friedman_ and _N. J. A. Sloane_
%E A034388 Edited by _M. F. Hasler_, Feb 25 2016
%E A034388 Edited by _Robert Israel_, Feb 26 2016