%I #18 May 30 2024 06:53:22
%S 1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,3,4,4,4,4,
%T 3,4,4,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
%U 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4
%N a(n) is the size of the largest set of positive integers S from 1..prime(n)-1 such that for any subset R of S, Sum {R} + prime(n) is prime.
%C This sequence is not monotonically increasing.
%e Let n=5, so p=prime(5)=11. From A070046, there are 3 positive integers x such that 1 <= x < 11 and 11+x is prime, which are {2, 6, 8}, so a(5) <= 3. Next, we see that 11 + 2 + 6 + 8 = 27 which is not prime so a(5) < 3. Last, we see that 11 + 2 + 6 = 19 is prime, and we already checked that 11 + 2 and 11 + 6 were prime, so S = {2, 6} and a(5) = 2.
%e 11 is the first n such that a(n) = 3. Here, prime(11) = 31, and there are multiple sets which work. One is S = {6, 22, 30}.
%e 31 + {} = 31 (empty set subset of S),
%e 31 + 6 = 37,
%e 31 + 22 = 53,
%e 31 + 30 = 61,
%e 31 + 6 + 22 = 59,
%e 31 + 6 + 30 = 67,
%e 31 + 22 + 30 = 83,
%e 31 + 6 + 22 + 30 = 89, all of which are prime.
%e 28 is the first n such that a(n) = 4. Here, prime(28) = 107, and there are multiple sets which work. One is S = {2, 30, 42, 90}.
%p f:= proc(n)
%p local k,p,C,S,s,t,q;
%p p:= ithprime(n);
%p C:= select(isprime,[$p+1 .. 2*p-1]) -~ p;
%p S[1]:= map(t -> [{t},{0,t}],C);
%p for k from 2 do
%p S[k]:= NULL;
%p for s in S[k-1] do
%p for t in select(`>`,C,max(s[1])) do
%p q:= s[2] +~ t;
%p if andmap(isprime, q +~ p) then
%p S[k]:= S[k], [s[1] union {t}, s[2] union q] ;
%p fi
%p od od;
%p S[k]:= {S[k]};
%p if S[k] = {} then return k-1 fi
%p od
%p end proc:
%p map(f, [$1..90]); # _Robert Israel_, May 06 2024
%t nmax = 87; a372406 = {{1, 1}};
%t For[n = 2, n <= nmax, n++, d = {}; p = Prime[n];
%t For[a = 2, a < p, a += 2, If[PrimeQ[p + a], AppendTo[d, a]]]; q = 1; k = 0;
%t While[q == 1 && k <= Length[d], k++; su = Subsets[d, {k}];
%t For[i = 1, i <= Length[su], i++, s = su[[i]];
%t If[PrimeQ[Total[s] + p], y = Subsets[s]; t = 1;
%t For[z = 1, z <= Length[y], z++,
%t If[CompositeQ[Total[y[[z]]] + p], t = 0; q = 0; Break[]]];
%t If[t == 1, q = 1; Break[]], q = 0]]];
%t AppendTo[a372406, {n, k - 1}]]
%t Print[a372406]
%Y Cf. A070046.
%K nonn
%O 1,4
%A _Samuel Harkness_, Apr 29 2024