[go: up one dir, main page]

login
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).
12
1, 2, 4, 11, 39, 148, 731, 4333, 26519, 152526, 1251724, 7627713, 49545041, 342729012
OFFSET
1,2
COMMENTS
From David A. Corneth, Jan 25 2022: (Start)
a(12) >= 7627713. a(13) >= 49545041.
There are A006879(12) = 33489857205 primes with 12 digits. There are 2.4*10^11 numbers with 12 digits that are coprime to 30 (i.e. end in 1, 3, 7, 9 and have a digital sum not divisible by 3).
On average one in 2.4*10^11/33489857205 ~= 7.166 of these numbers with 12 digits is prime.
Let maxqprimes(d) be the number of permutations of digits of d without leading 0 and ending in 1, 3, 7 or 9.
Let qprimes(d) be the number of permutations of digits of d (without leading 0 and ending in 1, 3, 7 or 9) that are prime.
a(12) = 7627713 if for some number with 12 digits we have maxprimes(d)/qprimes(d) < 5 (found via a brute force check). This is much less than the expected 7.166.
(At least) 101233456789 with 12 digits has maxqprimes(101233456789) = 54432000. This d = 101233456789 has a shared record for largest value for maxqprimes(d), along with d in {101234567789, 101234567899, 102334567789, 102345677899}. This gives maxqprimes(101233456789)/qprimes(101233456789) ~= 7.136, close to the expected 7.166.
The values d that have maxqprimes(d) >= 5*7627713 all have maxqprimes(d)/qprimes(d) >= 7.13.
For a(12) there are 2.4*10^11 checks needed if we do not use the found bound of 7627713. If we do we can bring down the search space by a factor of about 4 (without any heuristic). If we increase to 7*7627713 we only have about 9*10^8 needed checks left to do. (End)
EXAMPLE
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
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 *)
PROG
(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
(C) /* See links. */
CROSSREFS
KEYWORD
nonn,base,more
AUTHOR
Sascha Kurz, Nov 24 2001
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
STATUS
approved