A140532 Number of primes with n distinct decimal digits, none of which are 0.
4, 20, 83, 395, 1610, 5045, 12850, 23082, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Offset: 1
Examples
a(1) = #{2,3,5,7} = 4. a(2) = #{13,17,19,23,...,97} = 20. Note that the prime 11 is omitted because its decimal digits are not distinct.
Programs
-
Mathematica
Length /@ Table[Select[FromDigits /@ Permutations[Range@9, {i}], PrimeQ], {i,9}] (* Wei Zhou, Oct 02 2011 *)
-
Python
from itertools import permutations from sympy import isprime, primerange def distinct_digs(n): s = str(n); return len(s) == len(set(s)) def a(n): if n >= 9: return 0 return sum(isprime(int("".join(p))) for p in permutations("123456789", n)) print([a(n) for n in range(1, 30)]) # Michael S. Branicky, Apr 20 2021
Extensions
Corrected by Charles R Greathouse IV, Aug 02 2010
Comments