%I #28 Mar 29 2015 11:48:35
%S 4,2,3,1,5,6,12,13,9,7,15,8,10,11,16,19,14,22,17,20,21,18,25,23,26,28,
%T 27,29,34,24,32,36,42,35,41,30,33,31,40,46,43,39,38,48,44,47,45,50,37,
%U 56,51,49,55,60,58,63,53,64,62,52,54,66,57,69,70,80,61,68,59,65,71,72,81,76,83
%N For n >= 1, a(n) is the smallest number not already used such that the sum of the first n terms is semiprime.
%C Is this a permutation of the natural numbers? - _Derek Orr_, Feb 07 2015
%e a(3) = 3 because 3 is the smallest number not already used such that the sum of all 3 terms (4 + 2 + 3 = 9) is semiprime.
%p N:= 1000: # get all terms before the first term > N
%p S:= {$1..N} minus {4}:
%p T:= 4: A[1]:= 4:
%p for n from 2 do
%p found:= false;
%p for s in S do
%p if numtheory:-bigomega(s+T) = 2 then
%p A[n]:= s;
%p S:= S minus {s};
%p T:= s + T;
%p found:= true;
%p break
%p fi
%p od:
%p if not found then break fi;
%p od:
%p seq(A[i],i=1..n-1); # _Robert Israel_, Mar 24 2015
%t f[n_] := Block[{k, s = Select[Range[2(n^2 + n)/3], PrimeOmega@ # == 2 &], t = Table[4, {n}]}, For[k = 2, k <= n, k++, t[[k]] = Min@ Select[s - Total[Take[t, k - 1]], # > 0 && ! MemberQ[t, #] &]]; t]; f@ 75 (* _Michael De Vlieger_, Mar 24 2015 *)
%o (PARI) v=[4];n=1;while(n<100,if(bigomega(vecsum(v)+n)==2&&!vecsearch(vecsort(v),n),v=concat(v,n);n=0);n++);v \\ _Derek Orr_, Feb 07 2015
%Y Cf. A001358.
%K nonn,easy
%O 1,1
%A _G. L. Honaker, Jr._, Jan 23 2015
|