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.

A069869 Largest prime that is a concatenation of the parts of a partition of n, or 0 if no such prime exists.

This page as a plain text file.
%I A069869 #21 Feb 21 2024 16:49:39
%S A069869 0,11,3,211,2111,0,112111,1111211,0,11131111,1121111111,0,
%T A069869 111211111111,2111111111111,0,31111111111111,212111111111111,0,
%U A069869 1111111111111111111,2111111111111111111,0,111111111111111121111,11111111111111111111111,0,211111111111111111111111
%N A069869 Largest prime that is a concatenation of the parts of a partition of n, or 0 if no such prime exists.
%C A069869 Conjecture: a(n) = 0 only for n = 1 or n = 3k with k>1.
%H A069869 Alois P. Heinz, <a href="/A069869/b069869.txt">Table of n, a(n) for n = 1..200</a>
%e A069869 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.
%p A069869 with(combinat):
%p A069869 a:= proc(n) local k, w;
%p A069869       if n=1 or n>3 and irem(n, 3)=0 then return 0 fi;
%p A069869       for k from 0 do w:= max(select(isprime,
%p A069869         map(x-> parse(cat(x[])), [seq(permute(i)[],
%p A069869           i=map(x->[x[], 1$(n-k)], partition(k)))]))[]);
%p A069869         if w>0 then return w fi
%p A069869       od
%p A069869     end:
%p A069869 seq(a(n), n=1..30);  # _Alois P. Heinz_, May 25 2013
%t A069869 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]
%o A069869 (Python)
%o A069869 from collections import Counter
%o A069869 from operator import itemgetter
%o A069869 from sympy.utilities.iterables import partitions, multiset_permutations
%o A069869 from sympy import isprime
%o A069869 def A069869(n):
%o A069869     smax, m = 0, 0
%o A069869     if n==3 or n%3:
%o A069869         for s, p in sorted(partitions(n,size=True),key=itemgetter(0),reverse=True):
%o A069869             if s<smax:
%o A069869                 break
%o A069869             for a in multiset_permutations(Counter(p).elements()):
%o A069869                 if isprime(k:=int(''.join(str(d) for d in a))):
%o A069869                     m = max(k,m)
%o A069869             if m>0:
%o A069869                 smax=s
%o A069869     return m # _Chai Wah Wu_, Feb 21 2024
%Y A069869 Cf. A069870, A004022.
%K A069869 nonn,base
%O A069869 1,2
%A A069869 _Amarnath Murthy_, Apr 21 2002
%E A069869 More terms from _David Wasserman_, Apr 30 2003
%E A069869 a(8) corrected and a(16)-a(24) added by _Robert G. Wilson v_, Feb 06 2006
%E A069869 a(25) from _Alois P. Heinz_, May 25 2013