%I #27 Dec 05 2024 18:07:44
%S 2,3,5,7,167,523,617,761,1427,2417,2741,4127,4217,4271,4721,126241,
%T 126421,146221,212461,216421,221461,224611,226141,241261,242161,
%U 246121,261241,262411,264211,421621,426211,621241,642121,642211,1111457,1111547,1115417,1117451
%N Primes whose product of digits equals the number of digits times the sum of digits.
%H Michael S. Branicky, <a href="/A064155/b064155.txt">Table of n, a(n) for n = 1..10000</a> (terms 1..100 from Harry J. Smith)
%e 167 belongs to the sequence because 1*6*7 = 42 and 3*(1+6+7) = 42.
%t Select[Prime@Range@1000000, Plus@@(i=IntegerDigits@#)*Length@i == Times@@i&] (*_Hans Rudolf Widmer_, Jun 13 2024*)
%o (PARI) isok(k)={ if(isprime(k), my(d=digits(k)); vecprod(d)==#d * vecsum(d), 0) } \\ _Harry J. Smith_, Sep 09 2009
%o (Python)
%o from math import prod
%o from sympy import isprime
%o from sympy.utilities.iterables import multiset_permutations as mp
%o from itertools import count, islice, combinations_with_replacement as mc
%o def c(s):
%o d = list(map(int, s))
%o return prod(d) == len(d)*sum(d)
%o def agen():
%o yield from (2, 3, 5, 7)
%o for d in count(2):
%o okset = set()
%o for cand in ("".join(m) for m in mc("987654321", d)):
%o if c(cand):
%o for p in mp(cand, d):
%o t = int("".join(p))
%o if isprime(t): okset.add(t)
%o yield from sorted(okset)
%o print(list(islice(agen(), 38))) # _Michael S. Branicky_, Nov 30 2022
%Y Primes in A064154.
%K easy,nonn,base
%O 1,1
%A _Felice Russo_, Sep 14 2001
%E Name edited by _Andrew Howroyd_, Dec 05 2024