A065851 Let u be any string of n digits from {0,...,9}; let f(u) = number of distinct primes, not beginning with 0, formed by permuting the digits of u; then a(n) = max_u f(u).
1, 2, 4, 11, 39, 148, 731, 4333, 26519, 152526, 1251724, 7627713, 49545041, 342729012
Offset: 1
Examples
a(2) = 2 because 13 and 31 are primes. a(3) = 4 because {149, 419, 491, 941} or {179, 197, 719, 971} or {379, 397, 739, 937} are primes. - _R. J. Mathar_, Apr 23 2016
Links
- Kevin Ryde, C Code
Crossrefs
Programs
-
C
/* See links. */
-
Mathematica
c[x_] := Module[{}, Length[Select[Permutations[x], First[#] != 0 && PrimeQ[FromDigits[#, 10]] &]]]; A065851[n_] := Module[{i}, Return[Max[Map[c, DeleteDuplicatesBy[Tuples[Range[0, 9], n], Table[Count[#, i], {i, 0, 9}] &]]]]]; Table[A065851[n], {n, 1, 6}] (* Robert Price, Mar 30 2019 *)
-
Python
from sympy import isprime from itertools import combinations_with_replacement from sympy.utilities.iterables import multiset_permutations def a(n): return max(sum(1 for p in multiset_permutations(u) if p[0] != "0" and isprime(int("".join(p)))) for u in combinations_with_replacement("0123456789", n) if sum(int(ui) for ui in u)%3) print([a(n) for n in range(1, 7)]) # Michael S. Branicky, Jan 24 2022
-
Python
from collections import Counter from gmpy2 import next_prime, digits def A065851(n, base=10): # change base for A065843-A065850 c, p = Counter(), next_prime(base**(n-1)) while p < base**n: c["".join(sorted(digits(p, base)))] += 1 p = next_prime(p) m = min(c.most_common(1)) return m[1] print([A065851(n) for n in range(1, 8)]) # Michael S. Branicky, May 28 2024
Extensions
1 more term from Sean A. Irvine, Sep 06 2009
Definition corrected by David A. Corneth, Apr 23 2016
a(11) from David A. Corneth, Jan 25 2022
a(12)-a(14) from Kevin Ryde, Jul 09 2024
Comments