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-8 of 8 results.

A265733 Number of n-digit primes whose digits include at least n-1 digits "1".

Original entry on oeis.org

4, 8, 10, 9, 10, 13, 7, 16, 10, 11, 11, 13, 9, 11, 6, 7, 8, 16, 7, 11, 8, 9, 9, 10, 8, 12, 6, 13, 13, 21, 7, 12, 8, 7, 15, 16, 8, 9, 17, 9, 5, 22, 9, 15, 6, 12, 9, 20, 11, 13, 14, 11, 13, 12, 9, 15, 7, 4, 8, 12, 4, 11, 8, 15, 10, 17, 12, 12, 4, 9, 9, 14, 8, 14, 10, 7, 10, 14, 5, 14
Offset: 1

Views

Author

Keywords

Comments

Inspired by A241100 and its conjecture by Chai Wah Wu of Dec 10 2015.
The average value of a(n) is 10.6, median is 10, and mode is 11 for the first 1000 terms.
The first occurrence of k>0: 433, 361, 229, 1, 41, 15, 7, 2, 4, 3, 10, 26, 6, 51, 35, 8, 39, 180, 84, 48, 30, 42, 306, 138, 948, 642, ..., .
0 < a(n) < 27 for n < 1551.
It appears that a(n)/(9*n + 0^(n-1)) has its maximum at n = 2. - Altug Alkan, Dec 16 2015

Examples

			a(1) = 4 because {2, 3, 5, 7} are primes;
a(2) = 8 because {11, 13, 17, 19, 31, 41, 61, 71} are two digit primes with at least one digit being 1;
a(3) = 10 because {101, 113, 131, 151, 181, 191, 211, 311, 811, 911} are three digit primes with at least two digit being 1, etc.
		

Crossrefs

Programs

  • Maple
    A:= proc(n) local x,X,i,y;
      x:= (10^n-1)/9;
      y:= [x,seq(seq(x+10^i*y,y=1..8),i=0..n-1),seq(x - 10^i,i=0..n-2)];
      nops(select(isprime,y))
    end proc:
    map(A, [$1..100]); # Robert Israel, Dec 31 2015
  • Mathematica
    f1[n_] := Block[{cnt = k = 0, r = (10^n - 1)/9, s = {-1, 1, 2, 3, 4, 5, 6, 7, 8}}, If[ PrimeQ@ r, cnt++]; If[ PrimeQ[(10^(n - 1) - 1)/9], cnt--]; While[k < n, p = Select[r + 10^k*s, PrimeQ]; cnt += Length@ p; k++]; cnt]; Array[f1, 70]

Formula

Number of n-digit primes of the form 111...d...111, where the number of ones is at least n-1 and d is any other decimal digit.

A241206 Greatest n-digit prime having at least n-1 identical digits.

Original entry on oeis.org

7, 97, 997, 9949, 99991, 999979, 9999991, 99999989, 999999929, 9999999929, 99999999599, 999999999989, 9999999999799, 99999999999959, 999999999999989, 9999999999999199, 99999999999999997, 999999999999999989, 9999999999999999919, 99999999999999999989, 999999999999999999899, 9999999999999999999929
Offset: 1

Views

Author

Michel Lagneau, Apr 17 2014

Keywords

Comments

Not the same as A069661 (Smallest n-digit prime with maximum digit sum). For example, A069661(10) = 9899989999 with only n-2 = 8 identical digits.
Conjecture: each term consists of at least n-1 digits 9 and no digit 0. - Chai Wah Wu, Dec 10 2015

Crossrefs

Programs

  • Maple
    with(numtheory):lst:={}:nn:=30: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]:=9:
         od:
         ii:=0:
            for j from 1 to n while(ii=0)do:
            for k from 9 by -1 to 0 while(ii=0)do:
            T[n-j+1]:=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[n-j+1]:=9:
             fi:
           od:
         od:
        od :
         print(U) :
  • Mathematica
    Table[SelectFirst[Reverse@ Prime@ Range[PrimePi[10^(n - 1)] + 1, PrimePi[10^n - 1]], Max@ DigitCount@ # >= (n - 1) &], {n, 2, 8}]
    (* WARNING: the following assumes the conjecture is true WARNING *)
    Table[SelectFirst[Select[Reverse@ Union@ Map[FromDigits, Join @@ Map[Permutations[Append[Table[9, {n - 1}], #]] &, Range[0, 9]]], PrimeQ@ # && IntegerLength@ # == n &], Max@ DigitCount@ # >= (n - 1) &], {n, 2, 20}] (* Michael De Vlieger, Dec 10 2015, Version 10 *)
  • Python
    from _future_ import division
    from sympy import isprime
    def A241206(n):
        for i in range(9,0,-1):
            x = i*(10**n-1)//9
            for j in range(n-1,-1,-1):
                for k in range(9-i,-1,-1):
                    y = x + k*(10**j)
                    if isprime(y):
                        return y
            for j in range(n):
                for k in range(1,i+1):
                    if j < n-1 or k < i:
                        y = x-k*(10**j)
                        if isprime(y):
                            return y # Chai Wah Wu, Dec 29 2015

Extensions

a(1) added - N. J. A. Sloane, Dec 29 2015

A268702 Largest n digit prime having at least n-1 digits equal to 1.

Original entry on oeis.org

7, 71, 911, 8111, 16111, 911111, 1171111, 71111111, 131111111, 1711111111, 31111111111, 311111111111, 5111111111111, 41111111111111, 111151111111111, 5111111111111111, 11111611111111111, 191111111111111111, 2111111111111111111, 11111111611111111111
Offset: 1

Views

Author

Keywords

Examples

			a(3) = 911 since 111, 211, 311, ..., 811 are all composites but 911 is prime. Also of the ten primes of 3 digits which contain at least 2 ones, {101, 113, 131, 151, 181, 191, 211, 311, 811, 911}, 911 is the greatest.
		

Crossrefs

Programs

  • Mathematica
    f[n_] := Block[{k = 0, p = {}, r = (10^n - 1)/9, s = Range@ 10 - 2}, While[k < n, AppendTo[p, Select[r + 10^k*s, PrimeQ]]; k++]; p = Max@ Flatten@ p]; Array[f, 20]
  • PARI
    a(n) = {p = precprime(10^n-1); while (#select(x->x==1, digits(p)) != n-1, p = precprime(p-1)); p;} \\ Michel Marcus, Feb 21 2016

A268707 Smallest n-digit prime having at least n-1 digits equal to 9.

Original entry on oeis.org

2, 19, 199, 1999, 49999, 199999, 2999999, 19999999, 799999999, 9199999999, 59999999999, 959999999999, 9919999999999, 59999999999999, 499999999999999, 9299999999999999, 99919999999999999, 994999999999999999, 9991999999999999999, 29999999999999999999
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Mathematica
    f[n_] := Block[{k = 0, p = {}, r = (10^n - 1), s = Range@ 10 - 10}, While[k < n - 0, AppendTo[p, Select[r + 10^k*s, PrimeQ]]; k++]; p = Min@ Flatten@ p]; Array[f, 20]
  • PARI
    a(n)=my(t=10^n-1,p); forstep(d=n-1,0,-1, forstep(k=8,1,-1, p=t-10^d*k; if(ispseudoprime(p), return(p)))); -1 \\ Charles R Greathouse IV, Mar 21 2016

A268703 Smallest n-digit prime having at least n-1 digits equal to 3.

Original entry on oeis.org

2, 13, 233, 2333, 23333, 313333, 3233333, 31333333, 333233333, 3233333333, 23333333333, 333313333333, 3333333333383, 33133333333333, 323333333333333, 1333333333333333, 23333333333333333, 333333133333333333, 3333313333333333333, 33313333333333333333
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Mathematica
    f[n_] := Block[{k = 0, p = {}, r = (10^n - 1)/3, s = Range@ 10 - 4}, While[k < n, AppendTo[p, Select[r + 10^k*s, PrimeQ]]; k++]; p = Min@ Flatten@ p]; f[1] = 2; f[2] = 13; Array[f, 20]

A268706 Largest n-digit prime having at least n-1 digits equal to 7.

Original entry on oeis.org

7, 97, 977, 7877, 97777, 787777, 7877777, 77777747, 787777777, 8777777777, 79777777777, 777777779777, 7877777777777, 77777779777777, 778777777777777, 8777777777777777, 77797777777777777, 797777777777777777, 7777877777777777777, 97777777777777777777
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Maple
    f:= proc(n)
      local r,i,j,p;
      r:= 7*(10^n-1)/9;
      for p in sort([r, seq(seq(r + i*10^j, i=[$(-7)..(-1),1,2]),j=0..n-1)],`>`) do
        if isprime(p) then return p fi
      od;
      error("no prime found")
    end proc:
    map(f, [$1..100]); # Robert Israel, Feb 24 2016
  • Mathematica
    f[n_] := Block[{k = 0, p = {}, r = 7 (10^n - 1)/9, s = Range@ 10 - 8}, While[k < n, AppendTo[p, Select[r + 10^k*s, PrimeQ]]; k++]; p = Max@ Flatten@ p]; Array[f, 20]

A268704 Greatest n-digit prime having at least n-1 digits equal to 3.

Original entry on oeis.org

7, 83, 733, 7333, 38333, 733333, 3733333, 83333333, 373333333, 3334333333, 38333333333, 383333333333, 3433333333333, 53333333333333, 383333333333333, 3733333333333333, 43333333333333333, 353333333333333333, 3333334333333333333, 33343333333333333333
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Mathematica
    f[n_] := Block[{k = 0, p = {}, r = (10^n - 1)/3, s = Range@ 10 - 4}, While[k < n, AppendTo[p, Select[r + 10^k*s, PrimeQ]]; k++]; p = Max@ Flatten@ p]; Array[f, 20]
    Table[Max[Select[FromDigits/@Flatten[Permutations/@Table[PadRight[{n},k,3],{n,{1,2,4,5,7,8}}],1],IntegerLength[#]==k&&PrimeQ[#]&]],{k,20}] (* Harvey P. Dale, Apr 11 2020 *)

A268705 Smallest n-digit prime having at least n-1 digits equal to 7.

Original entry on oeis.org

2, 17, 277, 1777, 47777, 727777, 7477777, 77767777, 577777777, 1777777777, 67777777777, 377777777777, 7177777777777, 17777777777777, 577777777777777, 2777777777777777, 77777767777777777, 377777777777777777, 2777777777777777777, 71777777777777777777
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Mathematica
    f[n_] := Block[{k = 0, p = {}, r = 7(10^n - 1)/9, s = Range@ 10 - 8}, While[k < n, AppendTo[p, Select[r + 10^k*s, PrimeQ]]; k++]; p = Min@ Flatten@ p]; f[1] = 2; f[2] = 17; Array[f, 20]
    Table[Min[Select[FromDigits/@Flatten[Permutations/@Table[Join[ {n},PadRight[ {},k,7]],{n,0,9}],1],IntegerLength[#]==k+1&&PrimeQ[#]&]],{k,0,20}] (* Harvey P. Dale, Jan 23 2021 *)
Showing 1-8 of 8 results.