OFFSET
1,1
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000 (terms 1..100 from Harry J. Smith)
EXAMPLE
167 belongs to the sequence because 1*6*7 = 42 and 3*(1+6+7) = 42.
MATHEMATICA
Select[Prime@Range@1000000, Plus@@(i=IntegerDigits@#)*Length@i == Times@@i&] (*Hans Rudolf Widmer, Jun 13 2024*)
PROG
(PARI) isok(k)={ if(isprime(k), my(d=digits(k)); vecprod(d)==#d * vecsum(d), 0) } \\ Harry J. Smith, Sep 09 2009
(Python)
from math import prod
from sympy import isprime
from sympy.utilities.iterables import multiset_permutations as mp
from itertools import count, islice, combinations_with_replacement as mc
def c(s):
d = list(map(int, s))
return prod(d) == len(d)*sum(d)
def agen():
yield from (2, 3, 5, 7)
for d in count(2):
okset = set()
for cand in ("".join(m) for m in mc("987654321", d)):
if c(cand):
for p in mp(cand, d):
t = int("".join(p))
if isprime(t): okset.add(t)
yield from sorted(okset)
print(list(islice(agen(), 38))) # Michael S. Branicky, Nov 30 2022
CROSSREFS
KEYWORD
easy,nonn,base
AUTHOR
Felice Russo, Sep 14 2001
EXTENSIONS
Name edited by Andrew Howroyd, Dec 05 2024
STATUS
approved