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

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

A178000 Largest n-digit prime with the maximum number of digits equal to 2.

Original entry on oeis.org

2, 29, 229, 2221, 22229, 922223, 9222229, 22222223, 222222227, 7222222229, 22222222223, 522222222229, 9222222222229, 22222222222229, 222222222222227, 9222222222222227, 72222222222222221, 222222222222222221
Offset: 1

Views

Author

Lekraj Beedassy, May 17 2010

Keywords

Comments

Select first for most 2's, then take the largest.
In more detail: To get a(n), look at the list of all the n-digit primes. Suppose k is the maximum number of 2's of any number on the list. Throw out any prime on the list that does not contain k 2's. Then a(n) = maximal number that is left on the list. - N. J. A. Sloane, Mar 20 2018
For n <= 1000, a(n) has at most two non-2's. What is the first n for which it has more than two? - Robert Israel, Mar 20 2018

Crossrefs

Programs

  • Maple
    # This program will return FAIL if a(n) has more than two digits <> 2.
    f:= proc(n)
       local k1,d2,k2,t;
       for k1 in [9,7,3,1] do if isprime(2/9*(10^n-1)+k1-2) then return 2/9*(10^n-1)+k1-2 fi od;
       for d2 from n to 2 by -1 do
         for k2 in [9,8,7,6,5,4,3] do
           for k1 in [9,7,3,1] do
             t:= 2/9*(10^(n)-1)+(k2-2)*10^(d2-1) + k1-2;
             if isprime(t) then return t fi;
      od od od:
      FAIL
    end proc:
    f(1):= 2:
    seq(f(n),n=1..30); # Robert Israel, Mar 20 2018
Showing 1-2 of 2 results.