login
Largest n-digit prime with the most digits equal to 9.
2

%I #14 Dec 20 2024 11:56:48

%S 7,97,997,9949,99991,999979,9999991,99999989,999999929,9999999929,

%T 99999999599,999999999989,9999999999799,99999999999959,

%U 999999999999989,9999999999999199,99999999999999997,999999999999999989,9999999999999999919,99999999999999999989,999999999999999999899,9999999999999999999929

%N Largest n-digit prime with the most digits equal to 9.

%C First maximum the number of 9's, then choose the largest.

%C From _Robert Israel_, Dec 18 2024: (Start)

%C This is believed to be different from A241206, as there should be infinitely many n for which there is no n-digit prime with n-1 digits equal to 9. No examples are known; the least such n is greater than 3400. (End)

%H Robert Israel, <a href="/A178007/b178007.txt">Table of n, a(n) for n = 1..996</a>

%p f:= proc(n) local i,j,a,b,x,y;

%p x:= 10^n-1;

%p for i from 0 to n-1 do

%p for a from 1 to 9 do

%p y:= x - a*10^i;

%p if isprime(y) then return y fi;

%p od od;

%p for i from 1 to n-1 do

%p for a from 1 to 9 do

%p for j from 0 to i-1 do

%p for b from 1 to 9 do

%p y:= x - a*10^i - b*10^j;

%p if isprime(y) then return y fi

%p od od od od;

%p FAIL

%p end proc:

%p map(f, [$1..30]); # _Robert Israel_, Dec 16 2024

%Y Cf. A037071, A105975, A003618, A241206, A266148.

%K nonn,base

%O 1,1

%A _Lekraj Beedassy_, May 17 2010

%E Corrected and more terms by _Robert Israel_, Dec 16 2024