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.

Showing 1-1 of 1 results.

A265433 Number of primes with digit sum n whose digit product is maximal among all numbers with digit sum n.

Original entry on oeis.org

0, 1, 1, 0, 1, 0, 2, 1, 0, 1, 2, 0, 5, 1, 0, 4, 3, 0, 8, 2, 0, 2, 2, 0, 10, 1, 0, 5, 4, 0, 8, 1, 0, 4, 2, 0, 17, 0, 0, 7, 4, 0, 13, 3, 0, 0, 3, 0, 17, 4, 0, 12, 1, 0, 13, 1, 0, 6, 2, 0, 18, 1, 0, 11, 0, 0, 24, 2, 0, 5, 1, 0, 25, 1, 0, 10, 2, 0, 23, 2, 0, 9, 1
Offset: 1

Views

Author

Chai Wah Wu, Dec 08 2015

Keywords

Comments

If n == 0 mod 3, then a(n) = 0.
If n == 1 mod 3, then primes with maximal digit product (if they exist) have digits 3 and either two digits 2 or a single digit 4.
If n == 2 mod 3, then primes with maximal digit product (if they exist) have digits 3 and a single digit 2 (see comment in A137269).
If n == 0 mod 3 or a(n) > 0, then a(n) = A137269(n). Terms a(n) coincide with A137269 except for n = 4, 38, 46, 65, 94, 107, 116, 128, 131, 140, 143, 149, 152, 170, 188, 227, ..., 767 (and most likely other n > 767). For these values of n, a(n) = 0 and A137269(n) > 0.
Conjecture: For n > 4, if n <> 0 mod 3 and a(n) = 0, then A137269(n) > 0 due to primes with only digits 2, 3, or 4.

Examples

			See examples in A137269. a(4) = 0 since the maximal digit product is 4 corresponding to the numbers 22 and 4, neither of which is prime.
		

Crossrefs

Programs

  • Mathematica
    f[n_] := Block[{g, a265437 = {1, 4, 38, 46, 65, 94, 107, 116, 128, 131, 140, 143, 149, 152, 170, 188, 227, 230, 248, 272, 293, 302, 317, 335, 344, 359, 371, 382, 404, 488, 530, 533, 551, 584, 626, 647, 722, 767, 803, 815, 866, 875, 893, 914, 920}},
      g[k_] := Length@ MaximalBy[k, Times @@ IntegerDigits@ # &];
      Which[MemberQ[a265437, n], 0,
       1 < n <= 3, 1,
       Mod[n, 3] == 0, 0,
       Mod[n, 3] == 1, g@ Select[FromDigits /@ Apply[Join, Map[Permutations, {Join[Table[3, {Floor[n/3] - 1}], {2, 2}], Join[Table[3, {Floor[n/3] - 1}], {4}]}]] /. x_ /; EvenQ@ x -> Nothing, PrimeQ],
       Mod[n, 3] == 2, g@ Select[FromDigits /@ Permutations@ Join[Table[3, {Floor[n/3]}], {2}] /. x_ /; EvenQ@ x -> Nothing, PrimeQ],
    True, -1]] (* Michael De Vlieger, Dec 11 2015, Version 10, reliant on values of A265437 *)
  • Python
    from _future_ import division
    from sympy.utilities.iterables import multiset_permutations
    from sympy import isprime
    def A265433(n):
        if n == 1:
            return 0
        if n == 3:
            return 1
        if (n % 3) == 0:
            return 0
        else:
            pmaxlist = ['3'*(n//3) + '2'] if (n % 3 == 2) else ['3'*(n//3 -1) + '22','3'*(n//3 -1) + '4']
            return sum(1 for p in pmaxlist for k in multiset_permutations(p) if isprime(int(''.join(k)))) # Chai Wah Wu, Dec 11 2015
Showing 1-1 of 1 results.