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-9 of 9 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

A065584 Smallest prime beginning with exactly n 1's.

Original entry on oeis.org

2, 13, 11, 1117, 11113, 111119, 11111101, 11111117, 111111113, 11111111129, 11111111113, 1111111111139, 11111111111123, 1111111111111013, 1111111111111123, 11111111111111101, 11111111111111119
Offset: 0

Views

Author

Robert G. Wilson v, Nov 28 2001

Keywords

Comments

Largest terms are only probable primes. Some terms of the sequence are also in A004022 (repunit primes) or A056710 (all digits same except last digit). All terms of A004022 are in the current sequence.
According to the Magma Calculator (at http://magma.maths.usyd.edu.au/calc/), all 201 terms in the table (and thus all 17 terms listed above) are, in fact, prime. - Jon E. Schoenfield, Aug 24 2009

Crossrefs

Cf. A004022 (repunit primes), A056710 (near-repdigit primes).

Extensions

Corrected by Don Reble, Jan 17 2007
Offset corrected by Sean A. Irvine, Sep 06 2023

A065582 Smallest prime ending in exactly n 9's.

Original entry on oeis.org

19, 199, 1999, 49999, 199999, 2999999, 19999999, 799999999, 10999999999, 59999999999, 1099999999999, 34999999999999, 59999999999999, 499999999999999, 14999999999999999, 139999999999999999, 1099999999999999999, 20999999999999999999, 29999999999999999999, 2099999999999999999999
Offset: 1

Views

Author

Robert G. Wilson v, Nov 28 2001

Keywords

Comments

From Jeppe Stig Nielsen, Jul 30 2022: (Start)
Can decrease, for example a(25) < a(24). So not the same as Smallest prime ending in n or more 9s.
a(n) can contain other 9s as well, for example a(46), a(118), a(156). (End)

Crossrefs

Programs

  • Mathematica
    Do[a = Table[9, {n} ]; k = 0; While[ b = FromDigits[ Join[ IntegerDigits[k], a]]; Mod[k, 10] == 9 || !PrimeQ[b], k++ ]; Print[b], {n, 1, 17} ]
  • PARI
    a(n)={ my(t=10^n, b=t-1, d=0); while(!isprime(b + t*d), d++; if(d%10==9, d++)); b + t*d } \\ Harry J. Smith, Oct 23 2009
    
  • Python
    from sympy import isprime
    def a(n):
        pow, end, i = 10**n, 10**n-1, 1
        while i%10 == 9 or not isprime(i*pow + end): i += 1
        return i*pow + end
    print([a(n) for n in range(1, 20)]) # Michael S. Branicky, Jul 30 2022

A065580 Smallest prime ending in exactly n 3's.

Original entry on oeis.org

3, 233, 2333, 23333, 733333, 10333333, 83333333, 1033333333, 17333333333, 23333333333, 2633333333333, 10333333333333, 53333333333333, 3233333333333333, 1333333333333333, 23333333333333333, 2033333333333333333, 10333333333333333333, 173333333333333333333, 1733333333333333333333
Offset: 1

Views

Author

Robert G. Wilson v, Nov 28 2001

Keywords

Crossrefs

Programs

  • Mathematica
    Do[a = Table[3, {n} ]; k = 0; While[ b = FromDigits[ Join[ IntegerDigits[k], a]]; Mod[k, 10] == 3 || !PrimeQ[b], k++ ]; Print[b], {n, 1, 17} ]
  • PARI
    a(n)={ my(t=10^n, b=(t-1)/3, d=0); while (!isprime(b + t*d), d++; if(d%10==3, d++)); b + t*d } \\ Harry J. Smith, Oct 23 2009

A065581 Smallest prime ending in exactly n 7's.

Original entry on oeis.org

7, 277, 1777, 47777, 2477777, 16777777, 137777777, 577777777, 1777777777, 67777777777, 377777777777, 16777777777777, 17777777777777, 577777777777777, 2777777777777777, 157777777777777777, 377777777777777777, 2777777777777777777, 97777777777777777777, 2477777777777777777777
Offset: 1

Views

Author

Robert G. Wilson v, Nov 28 2001

Keywords

Crossrefs

Programs

  • Mathematica
    Do[a = Table[7, {n} ]; k = 0; While[ b = FromDigits[ Join[ IntegerDigits[k], a]]; Mod[k, 10] == 7 || !PrimeQ[b], k++ ]; Print[b], {n, 1, 17} ]
    k7[n_]:=Module[{c=FromDigits[PadRight[{},n,7]],k=0},While[Nand[PrimeQ[k*10^n + c], Mod[k, 10] != 7],k++];k*10^n+c]; Array[k7,20] (* Harvey P. Dale, Jan 29 2013 *)
  • PARI
    a(n)={ my(t=10^n, b=7*(t-1)/9, d=0); while (!isprime(b + t*d), d++; if(d%10==7, d++)); b + t*d } \\ Harry J. Smith, Oct 23 2009

A084673 Smallest prime in which a digit appears n times.

Original entry on oeis.org

2, 11, 1117, 10111, 101111, 1111151, 11110111, 101111111, 1111111121, 11111111113, 101111111111, 1111111118111, 11111111111411, 111111111116111, 1111111111111181, 11111111101111111, 101111111111111111
Offset: 1

Views

Author

Harvey P. Dale, Jun 29 2003

Keywords

Comments

For n > 1, conjectured to be equal to A037055(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

Examples

			a(4)=10111 because 10111 is the smallest prime with four duplicate digits.
		

References

  • Liz Strachan, Numbers are Forever, Mathematical Facts and Curiosities, Constable, London, 2014, page 267.

Crossrefs

Programs

  • Mathematica
    Table[ First[ Select[ Prime[ Range[100000]], Max[ DigitCount[ # ]]==i & ]], {i, 6}] (* or *)
    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, While[ !PrimeQ[k] || Count[ IntegerDigits[k], b] != n, k++ ]; k]]; Table[ f[n, 1], {n, 2, 18}]
  • PARI
    A084673(n)=if(n>1,A037055(n),2) \\ M. F. Hasler, Feb 25 2016

Extensions

Edited and extended by Robert G. Wilson v, Jul 03 2003

A105436 Smallest prime that remains prime when a string of n 1's is appended to it.

Original entry on oeis.org

2, 3, 2, 2, 13, 3, 29, 7, 17, 17, 3, 3, 2, 3, 197, 5, 13, 173, 2, 13, 53, 73, 199, 2, 23, 73, 599, 239, 547, 59, 409, 1009, 1277, 19, 3, 383, 137, 13, 653, 103, 139, 227, 19, 127, 359, 193, 1123, 3, 97, 1447, 839, 109, 3, 47, 17, 7, 269, 2, 1657, 1973, 709, 5233, 809
Offset: 0

Views

Author

Lekraj Beedassy, Apr 08 2005

Keywords

Examples

			a(2)=2 because it is the first prime followed by 3,41,101,107,113,137,... all remaining primes when 11 is appended to each of them.
		

Crossrefs

Programs

  • Maple
    with(numtheory); for n from 1 to 100 do for i from 1 to 5000 do if isprime(ithprime(i)*10^n + sum(10^j, j=0..n-1)) then printf(`%d,`, ithprime(i)); break; fi: od:od: # James Sellers, Apr 09 2005
  • Mathematica
    f[n_] := Block[{k = 1, t = Table[1, {n}]}, While[id = IntegerDigits[ Prime[k]]; id[[ -1]] == 1 || !PrimeQ[ FromDigits[ Join[id, t]]], k++ ]; Prime[k]]; Table[ f[n], {n, 0, 62}] (* Robert G. Wilson v, Apr 09 2005 *)

Extensions

More terms from Robert G. Wilson v and James Sellers, Apr 09 2005

A376689 a(n) is the first number that is a prime times 3^n and ends in exactly n 1's.

Original entry on oeis.org

2, 21, 711, 240111, 51111, 45411111, 16059111111, 43761111111, 2121411111111, 328203111111111, 11862441111111111, 37253511111111111, 10630644111111111111, 141896571111111111111, 17806995411111111111111, 9675948111111111111111, 11187474501111111111111111, 235460890911111111111111111
Offset: 0

Views

Author

Robert Israel, Oct 01 2024

Keywords

Examples

			a(3) = 240111 because 240111 = 3^3 * 8893 with 8893 prime and 240111 ends with three 1's.
a(12) = 10630644111111111111, not 3721911111111111111, because although 3721911111111111111 = 3^12 * 7003432386871 with 7003432386871 prime, 3721911111111111111 ends in 14 1's rather than just 12.
		

Crossrefs

Cf. A065821.

Programs

  • Maple
    f:= proc(n) local x0,p;
          x0:= -(1-10^(-n))/9 mod 3^n;
          for p from x0*10^n+(10^n-1)/9 by 30^n do if isprime(p/3^n) and p mod 10^(n+1) <> (10^(n+1)-1)/9 then return p fi od
    end proc;
    map(f, [$0..20]);
Showing 1-9 of 9 results.