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.

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

This page as a plain text file.
%I A241206 #28 Jun 30 2025 13:32:18
%S A241206 7,97,997,9949,99991,999979,9999991,99999989,999999929,9999999929,
%T A241206 99999999599,999999999989,9999999999799,99999999999959,
%U A241206 999999999999989,9999999999999199,99999999999999997,999999999999999989,9999999999999999919,99999999999999999989,999999999999999999899,9999999999999999999929
%N A241206 Greatest n-digit prime having at least n-1 identical digits.
%C A241206 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.
%C A241206 Conjecture: each term consists of at least n-1 digits 9 and no digit 0. - _Chai Wah Wu_, Dec 10 2015
%H A241206 Chai Wah Wu, <a href="/A241206/b241206.txt">Table of n, a(n) for n = 1..1000</a> (corrected by _Georg Fischer_, Jan 20 2019)
%p A241206 with(numtheory):lst:={}:nn:=30:kk:=0:T:=array(1..nn):U:=array(1..20):
%p A241206    for n from 2 to nn do:
%p A241206      for i from 1 to n do:
%p A241206      T[i]:=9:
%p A241206      od:
%p A241206      ii:=0:
%p A241206         for j from 1 to n while(ii=0)do:
%p A241206         for k from 9 by -1 to 0 while(ii=0)do:
%p A241206         T[n-j+1]:=k:s:=sum('T[i]*10^(n-i)', 'i'=1..n):
%p A241206          if type(s,prime)=true and length(s)=n
%p A241206          then
%p A241206          ii:=1: kk:=kk+1:U[kk]:=s:
%p A241206          else
%p A241206          T[n-j+1]:=9:
%p A241206          fi:
%p A241206        od:
%p A241206      od:
%p A241206     od :
%p A241206      print(U) :
%t A241206 Table[SelectFirst[Reverse@ Prime@ Range[PrimePi[10^(n - 1)] + 1, PrimePi[10^n - 1]], Max@ DigitCount@ # >= (n - 1) &], {n, 2, 8}]
%t A241206 (* WARNING: the following assumes the conjecture is true WARNING *)
%t A241206 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 *)
%o A241206 (Python)
%o A241206 from __future__ import division
%o A241206 from sympy import isprime
%o A241206 def A241206(n):
%o A241206     for i in range(9,0,-1):
%o A241206         x = i*(10**n-1)//9
%o A241206         for j in range(n-1,-1,-1):
%o A241206             for k in range(9-i,-1,-1):
%o A241206                 y = x + k*(10**j)
%o A241206                 if isprime(y):
%o A241206                     return y
%o A241206         for j in range(n):
%o A241206             for k in range(1,i+1):
%o A241206                 if j < n-1 or k < i:
%o A241206                     y = x-k*(10**j)
%o A241206                     if isprime(y):
%o A241206                         return y # _Chai Wah Wu_, Dec 29 2015
%Y A241206 Cf. A069661, A241100, A178007.
%K A241206 nonn,base
%O A241206 1,1
%A A241206 _Michel Lagneau_, Apr 17 2014
%E A241206 a(1) added - _N. J. A. Sloane_, Dec 29 2015