login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A241206 Greatest n-digit prime having at least n-1 identical digits. 7
7, 97, 997, 9949, 99991, 999979, 9999991, 99999989, 999999929, 9999999929, 99999999599, 999999999989, 9999999999799, 99999999999959, 999999999999989, 9999999999999199, 99999999999999997, 999999999999999989, 9999999999999999919, 99999999999999999989 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,1
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
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..1000 (corrected by Georg Fischer, Jan 20 2019)
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 *)
PROG
(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
CROSSREFS
Sequence in context: A146758 A114019 A178007 * A127892 A125590 A068694
KEYWORD
nonn,base
AUTHOR
Michel Lagneau, Apr 17 2014
EXTENSIONS
a(1) added - N. J. A. Sloane, Dec 29 2015
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 19 03:33 EDT 2024. Contains 370952 sequences. (Running on oeis4.)