%I #18 Mar 26 2019 17:19:52
%S 0,0,0,0,1,0,1,0,0,1,2,0,0,0,1,2,0,0,0,2,0,1,1,0,1,2,1,0,0,2,0,0,0,2,
%T 1,1,1,0,1,3,0,0,0,2,0,0,1,1,1,1,1,2,0,0,1,1,0,1,3,1,1,0,1,0,0,1,0,1,
%U 1,3,0,0,1,2,1,1,0,2,0,1,0,0,2,1,1,2,1,1,0,0,0,2,0,2,2,2,0,2,0,0,1,1,1,0,0,0,3,2,0,1,0,1,2,0,0,2,1,0,2,1,1
%N Number of ways of representing n as the sum of one or more consecutive semiprimes.
%H Alois P. Heinz, <a href="/A186336/b186336.txt">Table of n, a(n) for n = 0..10000</a>
%e a(4) = 1: 4 = A001358(1) is the first semiprime.
%e a(10) = 2: 10 = A001358(1)+A001358(2) = 4+6 = A001358(4) = 10.
%e a(39) = 3: 39 = 6+9+10+14 = 10+14+15 = 39.
%p b:= proc(n) option remember; local k;
%p if n=0 then 0
%p else for k from b(n-1)+1
%p while isprime(k) or 2<>add(i[2], i=ifactors(k)[2])
%p do od; k
%p fi
%p end:
%p pis:= proc(n) option remember; local k;
%p if n<4 then 0
%p elif n=4 then 1
%p else k:= pis(n-1);
%p k +`if`(b(k+1)=n, 1 ,0)
%p fi
%p end:
%p ssp:= proc(i,j) option remember;
%p b(j) + `if`(i=j, 0, ssp(i, j-1))
%p end:
%p a:= proc(n) option remember; local i, j, cnt, s;
%p cnt:= 0;
%p j:= pis(n);
%p i:= j;
%p while i>0 do
%p s:= ssp(i,j);
%p if s<n then i:= i-1
%p elif s>n then j:= j-1
%p else cnt:= cnt+1;
%p i, j:= i-1, j-1
%p fi
%p od; cnt
%p end:
%p seq(a(n), n=0..200);
%t nmax = 120;
%t sp = Select[Range[nmax], PrimeOmega[#] == 2&];
%t lsp = Length[sp]; Clear[a]; a[_] = 0;
%t Do[n = Total[sp[[i ;; j]]]; a[n] = a[n]+1, {i, 1, lsp}, {j, i, lsp}];
%t Table[a[n], {n, 0, nmax}] (* _Jean-François Alcover_, Mar 13 2019 *)
%o (Haskell)
%o a186336 n = f $ takeWhile (<= n) a001358_list where
%o f [] = 0
%o f (sp:sps) = g sp sps + f sps
%o g spSum [] = fromEnum (spSum == n)
%o g spSum (sp:sps) | spSum < n = g (sp + spSum) sps
%o | spSum == n = 1
%o | otherwise = 0
%o -- _Reinhard Zumkeller_, Feb 28 2011
%Y Cf. A001358, A112020, A186337.
%K nonn
%O 0,11
%A _Alois P. Heinz_, Feb 18 2011
|