cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A064155 Primes whose product of digits equals the number of digits times the sum of digits.

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