OFFSET
1,2
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..10000
EXAMPLE
a(4) = 13 as the partitions of 4 are (4), (3, 1), ( 2, 2), (2, 1, 1) (1, 1, 1, 1). The primes that can be formed are 13, 31, 211 and 13 is the smallest prime using a partition.
MATHEMATICA
f[n_] := If[ PrimeQ@n, n, If[n > 5 && Mod[n, 3] == 0, 0, Block[{len = PartitionsP[n], p = IntegerPartitions[n], t = {}}, Do[ AppendTo[t, Select[FromDigits /@ Join @@@ IntegerDigits /@ Permutations@p[[i]], PrimeQ@# &]], {i, len}]; t = Union@Flatten@t; If[Length@t > 0, Min@t, 0]] ]]; Array[f, 72] (* Robert G. Wilson v, updated by Jean-François Alcover, Jan 29 2014 *)
PROG
(Python)
from collections import Counter
from sympy.utilities.iterables import partitions, multiset_permutations
from sympy import isprime
def A069870(n):
d = 10**n
smin, m = n+1, d
if n==3 or n%3:
for s in range(1, n+1):
if s>smin:
break
m = min((k for k in (int(''.join(str(d) for d in a)) for p in partitions(n, m=s) for a in multiset_permutations(Counter(p).elements())) if isprime(k)), default=d)
if m<d:
smin=s
if m == d:
return 0
else:
return m # Chai Wah Wu, Feb 21 2024
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Amarnath Murthy, Apr 21 2002
EXTENSIONS
Edited by David Wasserman, May 01 2003
Corrected by T. D. Noe, Nov 15 2006
STATUS
approved