login
Numbers which are sums of consecutive composites.
3

%I #15 Oct 27 2023 09:52:23

%S 4,6,8,9,10,12,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,

%T 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,48,49,50,51,52,53,54,55,

%U 56,57,58,59,60,62,63,64,65,66,67,68,69,70,71,72,74,75,76,77,78,79,80,81

%N Numbers which are sums of consecutive composites.

%C This is to composites A002808 as A034707 is to primes A000040. The complement of this sequence, numbers which are not sums of consecutive composites, begins 1, 2, 3, 5, 7, ... (A140464).

%e Every composite is in this sequence as one consecutive composite. We account for primes thus:

%e a(10) = 17 = 8 + 9.

%e a(12) = 19 = 9 + 10.

%e a(16) = 23 = 6 + 8 + 9.

%e a(22) = 29 = 14 + 15.

%e a(24) = 31 = 9 + 10 + 12.

%e a(30) = 37 = 4 + 6 + 8 + 9 + 10.

%e a(34) = 41 = 20 + 21 = 12 + 14 + 15.

%e a(36) = 43 = 21 + 22.

%e Not included = 47.

%e a(45) = 53 = 26 + 27 = 8 + 9 + 10 + 12 + 14.

%e a(51) = 59 = 18 + 20 + 21 = 6 + 8 + 9 + 10 + 12 + 14.

%e Not included = 61.

%e a(58) = 67 = 33 + 34 = 21 + 22 + 24 = 10 + 12 + 14 + 15 + 16.

%e a(62) = 71 = 35 + 36 = 22 + 24 + 25 = 4 + 6 + 8 + 9 + 10 + 12 + 14.

%e Not included = 73.

%e a(69) = 79 = 39 + 40.

%e a(73) = 83 = 14 + 15 + 16 + 18 + 20.

%e a(79) = 89 = 44 + 45.

%e a(87) = 97 = 48 + 49 = 22 + 24 + 25 + 26.

%e a(91) = 101 = 50 + 51.

%e a(93) = 103 = 51 + 52.

%p isA133576 := proc(n)

%p local i,j ;

%p for i from 1 do

%p if A002808(i) > n then

%p return false;

%p end if;

%p for j from i do

%p s := add( A002808(l),l=i..j) ;

%p if s > n then

%p break;

%p elif s = n then

%p return true;

%p end if;

%p end do:

%p end do:

%p end proc:

%p A133576 := proc(n)

%p local a;

%p if n = 1 then

%p return A002808(1) ;

%p else

%p for a from procname(n-1)+1 do

%p if isA133576(a) then

%p return a;

%p end if;

%p end do:

%p end if ;

%p end proc:

%p seq(A133576(n),n=1..71) ; # _R. J. Mathar_, Feb 14 2015

%t okQ[n_] := If[CompositeQ[n], True, MemberQ[IntegerPartitions[n, All, Select[Range[n], CompositeQ]], p_List /; Length[p] == Length[Union[p]] && AllTrue[Complement[Range[p[[-1]], p[[1]]], p], PrimeQ]]];

%t Select[Range[150], okQ] (* _Jean-François Alcover_, Oct 27 2023 *)

%Y Cf. A002808, A034707, A037174, A140464 (complement).

%K easy,nonn

%O 1,1

%A _Jonathan Vos Post_, Dec 26 2007