login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A069869 Largest prime that is a concatenation of the parts of a partition of n, or 0 if no such prime exists. 5
0, 11, 3, 211, 2111, 0, 112111, 1111211, 0, 11131111, 1121111111, 0, 111211111111, 2111111111111, 0, 31111111111111, 212111111111111, 0, 1111111111111111111, 2111111111111111111, 0, 111111111111111121111, 11111111111111111111111, 0, 211111111111111111111111 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
COMMENTS
Conjecture: a(n) = 0 only for n = 1 or n = 3k with k>1.
LINKS
EXAMPLE
a(4) = 211 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 211 is the largest prime using a partition.
MAPLE
with(combinat):
a:= proc(n) local k, w;
if n=1 or n>3 and irem(n, 3)=0 then return 0 fi;
for k from 0 do w:= max(select(isprime,
map(x-> parse(cat(x[])), [seq(permute(i)[],
i=map(x->[x[], 1$(n-k)], partition(k)))]))[]);
if w>0 then return w fi
od
end:
seq(a(n), n=1..30); # Alois P. Heinz, May 25 2013
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, Max@t, 0]] ]]; Array[f, 29]
PROG
(Python)
from collections import Counter
from operator import itemgetter
from sympy.utilities.iterables import partitions, multiset_permutations
from sympy import isprime
def A069869(n):
smax, m = 0, 0
if n==3 or n%3:
for s, p in sorted(partitions(n, size=True), key=itemgetter(0), reverse=True):
if s<smax:
break
for a in multiset_permutations(Counter(p).elements()):
if isprime(k:=int(''.join(str(d) for d in a))):
m = max(k, m)
if m>0:
smax=s
return m # Chai Wah Wu, Feb 21 2024
CROSSREFS
Sequence in context: A157883 A038317 A157781 * A079841 A110782 A088073
KEYWORD
nonn,base
AUTHOR
Amarnath Murthy, Apr 21 2002
EXTENSIONS
More terms from David Wasserman, Apr 30 2003
a(8) corrected and a(16)-a(24) added by Robert G. Wilson v, Feb 06 2006
a(25) from Alois P. Heinz, May 25 2013
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 13 11:48 EDT 2024. Contains 375138 sequences. (Running on oeis4.)