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.

A373179 a(n) is the smallest n-digit integer whose digit permutations make the maximum possible number of n-digit primes.

This page as a plain text file.
%I A373179 #40 Jul 16 2024 15:55:09
%S A373179 2,13,149,1237,13789,123479,1235789,12345679,102345679,1123456789,
%T A373179 10123456789,1011233456789,1012334567789,10123345677899
%N A373179 a(n) is the smallest n-digit integer whose digit permutations make the maximum possible number of n-digit primes.
%C A373179 A065851(n) is the maximum number of n-digit primes which can be made by permuting n digits.
%C A373179 a(n) = k is the smallest n-digit k for which A046810(k) = A065851(n).
%C A373179 a(n) has its relevant digits sorted and not beginning with 0 and may or may not be one of the primes (it is for n = 1 to 7, but not at n = 8).
%H A373179 Kevin Ryde, <a href="/A065851/a065851.c.txt">C Code</a>
%e A373179 For n=3, A065851(3) = 4 primes are reached by permuting the digits of a(3) = 149, namely {149, 419, 491, 941}. (4 primes are also reached from 179 and 379, but they're bigger numbers.)
%o A373179 (Python)
%o A373179 from sympy import nextprime
%o A373179 from collections import Counter
%o A373179 def smallest(t):
%o A373179     nz = "".join(sorted(c for c in t if c != "0"))
%o A373179     s = "".join(t) if "0" not in t else nz[0]+"0"*t.count("0")+nz[1:]
%o A373179     return int(s)
%o A373179 def a(n):
%o A373179     c, p = Counter(), nextprime(10**(n-1))
%o A373179     while p < 10**n:
%o A373179         c["".join(sorted(str(p)))] += 1
%o A373179         p = nextprime(p)
%o A373179     m = min(c.most_common(1), key=lambda x:smallest(x[0]))
%o A373179     return smallest(m[0])  # m[1] generates A065851
%o A373179 print([a(n) for n in range(1, 8)]) # _Michael S. Branicky_, May 28 2024
%o A373179 (C) /* See links. */
%Y A373179 Cf. A000040, A046810, A065851, A134596, A179239.
%K A373179 nonn,base,more
%O A373179 1,1
%A A373179 _Gonzalo Martínez_, May 26 2024
%E A373179 a(9)-a(11) from _Michael S. Branicky_, May 27 2024
%E A373179 a(12)-a(14) from _Kevin Ryde_, Jul 16 2024