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.

Showing 1-3 of 3 results.

A034388 Smallest prime containing at least n consecutive identical digits.

Original entry on oeis.org

2, 11, 1117, 11113, 111119, 2999999, 11111117, 111111113, 1777777777, 11111111113, 311111111111, 2111111111111, 17777777777777, 222222222222227, 1333333333333333, 11111111111111119, 222222222222222221, 1111111111111111111, 1111111111111111111
Offset: 1

Views

Author

Keywords

Comments

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

Examples

			a(1) = 2 because this is the smallest prime.
a(2) = 11 because this repunit with n=2 digits is prime.
a(3) = 1117 is the smallest prime with 3 repeated digits.
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).
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local d, k,x,y,z,xs,ys,zs,c,cands;
      for d from n do
        cands:= NULL;
        for k from 0 to d-n do
          if k = 0 then zs:= [0] else zs:= [seq(i,i=1..10^k-1,2)] fi;
          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;
          cands:= cands, seq(seq(seq(z + 10^k*y*(10^n-1)/9 + x*10^(k+n), x = xs),y=ys),z=zs);
        od;
        cands:= sort([cands]);
        for c in cands do if isprime(c) then return(c) fi od;
      od
    end proc:
    map(f, [$1..30]); # Robert Israel, Feb 26 2016
  • Mathematica
    With[{s = Length /@ Split@ IntegerDigits@ # & /@ Prime@ Range[10^6]}, Prime@ Array[FirstPosition[s, #][[1]] &, Max@ Flatten@ s]] (* Michael De Vlieger, Aug 15 2018 *)
  • 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

Extensions

Edited by M. F. Hasler, Feb 25 2016
Edited by Robert Israel, Feb 26 2016

A037055 Smallest prime containing exactly n 1's.

Original entry on oeis.org

2, 13, 11, 1117, 10111, 101111, 1111151, 11110111, 101111111, 1111111121, 11111111113, 101111111111, 1111111118111, 11111111111411, 111111111116111, 1111111111111181, 11111111101111111, 101111111111111111, 1111111111111111171, 1111111111111111111, 111111111111111119111
Offset: 0

Views

Author

Patrick De Geest, Jan 04 1999

Keywords

Comments

For n > 1, A037055 is conjectured to be identical to A084673. - Robert G. Wilson v, Jul 04 2003
a(n) = A002275(n) for n in A004023. For all other n < 900, a(n) has n+1 digits. - Robert Israel, Feb 21 2016

Crossrefs

Programs

  • Maple
    f:= proc(n) local m,d,r,x;
       r:= (10^n-1)/9;
       if isprime(r) then return r fi;
       r:= (10^(n+1)-1)/9;
       for m from n-1 to 1 by -1 do
         x:= r - 10^m;
         if isprime(x) then return x fi;
       od;
       for m from 0 to n do
         for d from 1 to 8 do
            x:= r + d*10^m;
            if isprime(x) then return x fi;
         od
       od;
       error("Needs more than n+1 digits")
    end proc:
    map(f, [$0..100]); # Robert Israel, Feb 21 2016
  • Mathematica
    f[n_, b_] := Block[{k = 10^(n + 1), p = Permutations[ Join[ Table[b, {i, 1, n}], {x}]], c = Complement[Table[j, {j, 0, 9}], {b}], q = {}}, Do[q = Append[q, Replace[p, x -> c[[i]], 2]], {i, 1, 9}]; r = Min[ Select[ FromDigits /@ Flatten[q, 1], PrimeQ[ # ] & ]]; If[r ? Infinity, r, p = Permutations[ Join[ Table[ b, {i, 1, n}], {x, y}]]; q = {}; Do[q = Append[q, Replace[p, {x -> c[[i]], y -> c[[j]]}, 2]], {i, 1, 9}, {j, 1, 9}]; Min[ Select[ FromDigits /@ Flatten[q, 1], PrimeQ[ # ] & ]]]]; Table[ f[n, 1], {n, 1, 18}]
    Join[{2, 13}, Table[Sort[Flatten[Table[Select[FromDigits/@Permutations[Join[{n}, PadRight[{}, i, 1]]], PrimeQ], {n, 0, 9}]]][[1]], {i, 2, 20}]] (* Vincenzo Librandi, May 11 2017 *)
  • PARI
    A037055(n)={my(p,t=10^(n+1)\9); forstep(k=n+1,1,-1, ispseudoprime(p=t-10^k) && return(p)); forvec(v=[[0, n], [1, 8]], ispseudoprime(p=t+10^v[1]*v[2]) && return(p))} \\ M. F. Hasler, Feb 22 2016

Formula

a(n) = the smallest prime in { R-10^n, R-10^(n-1), ..., R-10; R+a*10^b, a=1, ..., 8, b=0, 1, 2, ..., n }, where R = (10^(n+1)-1)/9 is the (n+1)-digit repunit. - M. F. Hasler, Feb 25 2016
a(n) = prime(A037054(n)). - Amiram Eldar, Jul 21 2025

Extensions

More terms from Sascha Kurz, Feb 10 2003
Edited by Robert G. Wilson v, Jul 04 2003
a(0) = 2 inserted by Robert Israel, Feb 21 2016

A385280 a(n) is the number of n-digit primes of which all digits except one are the same.

Original entry on oeis.org

4, 20, 46, 43, 40, 53, 35, 49, 40, 38, 44, 52, 35, 45, 49, 42, 38, 57, 27, 45, 38, 47, 37, 52, 33, 45, 56, 38, 36, 65, 29, 56, 48, 40, 38, 58, 37, 33, 57, 40, 37, 61, 41, 39, 37, 44, 36, 55, 47, 43, 47, 43, 35, 62, 43, 46, 29, 35, 37, 56, 39, 41, 46, 48, 39, 74, 45, 34, 34, 35, 34, 67, 39, 45, 43
Offset: 1

Views

Author

Robert Israel, Jun 24 2025

Keywords

Comments

a(n) is the number of n-digit primes obtained by changing one digit of an n-digit repdigit.

Examples

			a(5) = 40 because there are 40 5-digit primes of which all digits but one are the same, namely 10111, 11113, 11117, 11119, 11131, 11161, 11171, 11311, 11411, 16111, 22229, 23333, 31333, 33331, 33343, 33353, 33533, 38333, 44449, 47777, 49999, 59999, 67777, 71777, 76777, 77377, 77477, 77747, 77773, 77797, 77977, 79777, 79999, 88883, 94999, 97777, 98999, 99929, 99989, 99991.
		

Crossrefs

Essentially the same as A258915.

Programs

  • Maple
    f:= proc(n)
         local i,j,m, m2, t;
         t:= 0;
         for i from 1 to 9 do
           for j in {$0..9} minus {i} do
              if (n-1)*i + j mod 3 = 0 then next fi;
              if j = 0 then m2:= n-2 else m2:= n-1 fi;
              if not member(i,{1,3,7,9}) then m2:= 0 fi;
              t:= t + nops(select( isprime,{seq((10^n-1)/9*i + 10^m*(j-i),m=0..m2)}))
         od od;
         t
    end proc:
    f(1):= 4: f(2):= 20:
    map(f, [$1..100]);
  • Python
    from gmpy2 import is_prime, digits
    def a(n):
        Rn = (10**n-1)//9
        return len(set(t for d in range(1, 10) for i in range(n if d in {1, 3, 7, 9} else 1) for c in set(range(-d, 10-d))-{0} if len(digits(t:=d*Rn+c*10**i))==n and is_prime(t)))
    print([a(n) for n in range(1, 76)]) # Michael S. Branicky, Jun 25 2025
Showing 1-3 of 3 results.