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.

A241100 Smallest prime with length n having at least n-1 identical digits.

Original entry on oeis.org

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

Views

Author

Michel Lagneau, Apr 16 2014

Keywords

Comments

Conjecture: each term consists of at least n-1 digits 1. - Chai Wah Wu, Dec 10 2015
From Robert G. Wilson v, Dec 14 2015: (Start)
Terms for which the digit d is the other digit besides the 1's:
d:
0: 3, 5, 6, 8, 9, 12, 17, 18, 20, 24, 26, 29, 30, 32, 33, 35, 36, 38, 39, 42, ..., ; n cannot be congruent to 1 (mod 3);
1: 2, 19, 23, not 317, nor 1031, ..., (see A004023); n cannot be congruent to 0 (mod 3)
2: 1, 10, 34, 46, 67, 75, 100, 103, 142, 148, 154, 175, 198, 232, 244, 274, ..., ;
3: 11, 63, 69, 71, 87, 123, 125, 165, 191, 197, 203, 239, 254, 255, 275, 279, ..., ;
4: 14, 31, 55, 76, 85, 91, 95, 109, 121, 127, 130, 143, 155, 163, 166, 178, ..., ;
5: 7, 22, 28, 37, 45, 52, 60, 94, 111, 132, 133, 139, 159, 160, 172, 184, ..., ;
6: 15, 41, 57, 59, 135, 156, 171, 213, 311, 336, 339, 345, 347, 350, 431, ..., ;
7: 4, 40, 47, 58, 64, 70, 101, 106, 112, 115, 118, 131, 136, 145, 157, 169, ..., ;
8: 13, 16, 25, 43, 49, 61, 73, 79, 82, 88, 93, 97, 99, 117, 124, 141, 151, ..., ;
9: 21, 27, 65, 81, 119, 167, 179, 183, 189, 237, 242, 287, 299, 333, 356, ..., . (End)

Programs

  • Maple
    with(numtheory):lst:={}:nn:=80:kk:=0:T:=array(1..nn):U:=array(1..20):
       for n from 2 to nn do:
         for i from 1 to n do:
         T[i]:=1:
         od:
         ii:=0:
          for k from 0 to 9 while(ii=0)do:
            for j from 1 to n while(ii=0)do:
            T[j]:=k:s:=sum('T[i]*10^(n-i)', 'i'=1..n):
             if type(s,prime)=true and length(s)=n
             then
             ii:=1: kk:=kk+1:U[kk]:=s:
             else
             T[j]:=1:
             fi:
           od:
         od:
        od :
         print(U) :
  • Mathematica
    f[n_] := Block[{k = n - 2, p = 0, r = (10^n - 1)/9, s}, If[ Mod[n, 3] != 1, While[p = r - 10^k; k > 0 && ! PrimeQ@ p, k--]]; If[ Mod[p, 10] == 0, k = 0; s = Select[Range[0, 8], Mod[# + n, 3] > 0 &]; While[p = Select[r + 10^k*s, PrimeQ]; k < n && p == {}, k++]]; p = Min@ p]; Array[f, 20] (* Robert G. Wilson v, Dec 14 2015 *)
    Table[SelectFirst[Sort[Flatten[Table[Select[FromDigits/@Permutations[PadRight[{d},n,1]],IntegerLength[#] == n&],{d,0,9}]]],PrimeQ],{n,20}] (* Assumes that Chai Wah Wu's conjecture, above, is correct. *) (* Harvey P. Dale, Oct 23 2024 *)
  • Python
    from _future_ import division
    from sympy import isprime
    def A241100(n):
        for i in range(1,10):
            x = i*(10**n-1)//9
            for j in range(n-1,-1,-1):
                for k in range(i,-1,-1):
                    if j < n-1 or k < i:
                        y = x-k*(10**j)
                        if isprime(y):
                            return y
            for j in range(n):
                for k in range(1,9-i+1):
                    y = x+k*(10**j)
                    if isprime(y):
                        return y # Chai Wah Wu, Dec 29 2015

Extensions

a(4), a(7), a(10), a(11), a(13)-a(16) corrected by Chai Wah Wu, Dec 10 2015
a(1) from Robert G. Wilson v, Dec 11 2015