login
A178003
Largest n-digit prime with the most digits equal to 5.
1
5, 59, 557, 5557, 75557, 555557, 9555551, 55555559, 855555559, 5555555557, 75555555557, 555555555559, 5555555555551, 59555555555557, 555555555555557, 6555555555555553, 55556555555555557, 555555555555555559, 9555555555555555551, 85555555555555555559
OFFSET
1,1
COMMENTS
Select first for the most 5's, then take the largest.
LINKS
MAPLE
f:= proc(n) local x, m, xs, sets, s, i, cands;
for m from 1 do
xs:= subs({seq(i=i+1, i=5..8)}, map(t -> convert(9^m+t, base, 9)[1..m], [$1..9^m-1])):
sets:= map(t -> t union {1}, combinat:-choose({$2..n}, m-1)):
cands:=[seq(seq(subsop(seq(s[i]=x[i], i=1..m), [5$n]), s=sets), x=xs)]:
cands:= sort(map(proc(t) add(t[i]*10^(i-1), i=1..n) end proc, cands), `>`):
for x in cands do
if x < 10^(m-1) then break fi;
if isprime(x) then return x fi
od:
od:
end proc:
f(1):= 5:
map(f, [$1..20]); # Robert Israel, Nov 25 2025
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Lekraj Beedassy, May 17 2010
STATUS
approved