login
Smallest prime whose product of digits is 5^n.
6

%I #7 Nov 05 2021 09:13:09

%S 11,5,11551,15551,1551551,15551551,1155555151,1555551551,11555555551,

%T 1155155555551,555555515551,555555555551,5555555555551,

%U 555155555555551,51555555551555551,51555555555555551,1155555555555555551,15551555555555555551,1155515555555555555551

%N Smallest prime whose product of digits is 5^n.

%H Michael S. Branicky, <a href="/A090840/b090840.txt">Table of n, a(n) for n = 0..998</a>

%e a(4) = 1551551 because its digital product is 5^4, and it is prime.

%p a:= proc(n) local k, t; for k from 0 do t:= min(select(isprime,

%p map(x-> parse(cat(x[])), combinat[permute]([1$k, 5$n]))));

%p if t<infinity then return t fi od

%p end:

%p seq(a(n), n=0..18); # _Alois P. Heinz_, Nov 05 2021

%t NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; a = Table[0, {18}]; p = 2; Do[q = Log[5, Times @@ IntegerDigits[p]]; If[q != 0 && IntegerQ[q] && a[[q]] == 0, a[[q]] = p; Print[q, " = ", p]]; p = NextPrim[p], {n, 1, 10^9}]

%t For a(13); a = Map[ FromDigits, Permutations[{1, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}]]; Min[ Select[a, PrimeQ[ # ] &]]

%o (Python)

%o from sympy import isprime

%o from sympy.utilities.iterables import multiset_permutations as mp

%o def a(n):

%o if n < 2: return [11, 5][n]

%o digits = n + 1

%o while True:

%o for p in mp("1"*(digits-n-1) + "5"*n, digits-1):

%o t = int("".join(p) + "1")

%o if isprime(t): return t

%o digits += 1

%o print([a(n) for n in range(19)]) # _Michael S. Branicky_, Nov 05 2021

%Y Cf. A089365, A088653, A091465, A090841, A089298.

%K base,nonn

%O 0,1

%A _Robert G. Wilson v_, Dec 09 2003

%E a(17) and beyond from _Michael S. Branicky_, Nov 05 2021