%I #17 Jul 13 2022 15:54:09
%S 2,3,-1,5,5,7,-1,-1,7,11,7,13,-1,-1,-1,17,11,19,-1,-1,13,23,11,-1,-1,
%T -1,11,29,11,31,-1,-1,19,-1,11,37,-1,-1,11,41,13,43,-1,11,-1,47,11,-1,
%U -1,-1,17,53,11,-1,13,-1,31,59,13,61,-1,13,-1,-1,17,67,-1,-1,17,71,13,73,-1,13,23,-1
%N a(n) is the least prime that is the sum of a list of numbers > 1 whose product is n, or -1 if there is no such prime.
%C a(n) = n if and only if n is prime.
%C If n is in A046315, a(n) = -1.
%H Robert Israel, <a href="/A355618/b355618.txt">Table of n, a(n) for n = 2..10000</a>
%e a(12) = 7 because 7 = 3+4 is prime where 12 = 3*4, and no smaller prime works. This could also be done as 7 = 2+2+3 where 12 = 2*2*3.
%p G:= proc(S,n) option remember; local s, Sp;
%p if n = 1 then return {[]} fi;
%p Sp:= select(t -> n mod t = 0, S);
%p if Sp = {} then return {} fi;
%p s:= Sp[1];
%p map(t -> [s,op(t)], procname(S,n/s)) union procname(S[2..-1],n)
%p end proc:
%p f:= proc(n) local S;
%p S:= map(t -> convert(t,`+`), G(numtheory:-divisors(n) minus {1}, n));
%p subs(infinity=-1,min(select(isprime,S)))
%p end proc:
%p map(f, [$2..100]);
%o (PARI) mpartitions(k) = my(v, u); v=[[k]]; fordiv(k, d, if(d>1 && d<=sqrt(k), if(isprime(k/d), v=concat(v, [[d, k/d]]), u=mpartitions(k/d)); for(j=1, #u, if(vecprod(concat(d, u[j])) == k, v = concat(v, [vecsort(concat(d, u[j]))]))))); vecsort(Set(v))
%o a(n) = n=vecmin(apply(p->if(isprime(p=vecsum(p)), p, oo), mpartitions(n))); if(n<oo, n, -1) \\ _Iain Fox_, Jul 10 2022
%Y Cf. A046315.
%K sign,look
%O 2,1
%A _J. M. Bergot_ and _Robert Israel_, Jul 10 2022