login
A110456
Largest prime obtained by concatenation of parts of a distinct partition of n. 0 if no such number exist.
1
0, 2, 3, 31, 41, 0, 421, 521, 0, 4231, 5231, 0, 7321, 8231, 0, 64231, 74231, 0, 94321, 431021, 0, 754123, 854213, 0, 5431021, 6421013, 0, 8431021, 9431021, 0, 65412103, 75411023, 0, 95421103, 96412103, 0, 643110211, 765324101, 0, 965421013, 975431021, 0, 7542103111, 8543121011
OFFSET
1,2
COMMENTS
Conjecture a(n) = 0 only for n = 1, or n == 0 (mod 3), n is > 3. Subsidiary sequence (hard): Number of primes generated by concatenation of distinct partitions of n.
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..93
Michael S. Branicky, Python program
EXAMPLE
Distinct partitions of 10 are (10), (9,1), (8,2), (7,3), (6,4), (7,2,1), (6,3,1), (5,3,2), (5,4,1), (4,3,2,1). a(10) = 4231 is the largest prime obtained as a concatenation of (4,2,3,1).
PROG
(PARI) a(n) = my(best=0, cur); forpart(u=n, if(#Set(u)==#u, forperm(u, v, cur=eval(concat(apply(x->Str(x), Vec(v)))); if(isprime(cur), best=max(best, cur))))); best \\ Jason Yuen, Sep 05 2024
(Python) # see link for faster version
from itertools import permutations
from gmpy2 import digits, is_prime, mpz
def dparts(n, high=0): # distinct partitions of n with terms > high
if n > high: yield (n, )
for i in range(high+1, n):
yield from ((i, )+p for p in dparts(n-i, i))
def a(n):
return max((int(t) for dp in dparts(n) for p in permutations(list(map(str, dp))) if is_prime(t:=mpz("".join(p)))), default=0)
print([a(n) for n in range(1, 41)]) # Michael S. Branicky, Sep 07 2024
CROSSREFS
Sequence in context: A272043 A136150 A155056 * A128348 A029973 A344736
KEYWORD
base,nonn
AUTHOR
Amarnath Murthy, Aug 04 2005
EXTENSIONS
Corrected and extended by R. J. Mathar, Feb 08 2008
a(39) and beyond from Michael S. Branicky, Sep 07 2024
STATUS
approved