login
Numbers that can be written as both the sum of two or more consecutive nonprimes and the sum of two or more consecutive primes.
2

%I #37 Dec 31 2023 00:12:45

%S 5,10,17,18,23,26,28,31,36,39,41,49,53,58,59,60,67,68,71,75,77,78,83,

%T 84,90,95,97,101,102,109,112,121,124,127,128,129,131,132,138,139,143,

%U 150,152,155,156,158,159,160,161,162,168,169,172,173,180,181,184,187,192

%N Numbers that can be written as both the sum of two or more consecutive nonprimes and the sum of two or more consecutive primes.

%C It seems that more than one consecutive number set from one kind or the other may exist for a term. Also, for some terms, an equal number of addends from each kind may correspond.

%H David Consiglio, Jr., <a href="/A367021/b367021.txt">Table of n, a(n) for n = 1..1000</a>

%e 5 is a term because 5 = 1 + 4 = 2 + 3, which is the sum of two consecutive nonprimes and also the sum of two consecutive primes.

%e 17 is a term because 17 = 8 + 9 = 2 + 3 + 5 + 7, the sum of two consecutive nonprimes and also the sum of four consecutive primes.

%o (Python)

%o from sympy import isprime

%o primes = [x for x in range(2,3000) if isprime(x)]

%o comps = [x for x in range(1,3000) if not isprime(x)]

%o psums = set(sum(primes[p:p+pn]) for pn in range(2,100) for p in range(len(primes)-pn))

%o csums = set(sum(comps[c:c+cn]) for cn in range(2,100) for c in range(len(comps)-cn))

%o terms = sorted(list(psums.intersection(csums)))

%o print(terms)

%o # _David Consiglio, Jr._, Dec 18 2023

%Y Cf. A018252, A050936, A366976.

%K nonn

%O 1,1

%A _Tamas Sandor Nagy_, Nov 01 2023

%E More terms from _David Consiglio, Jr._, Dec 18 2023