login
a(n) is the maximum length of the sequence obtained with the same scheme as in A338134 but starting with n primes.
0

%I #19 Dec 18 2020 02:35:59

%S 1,2,3,13,18,26,66,176,313,657,1022,2575,5142,9269

%N a(n) is the maximum length of the sequence obtained with the same scheme as in A338134 but starting with n primes.

%e a(6) = 26, which is based on the length of the sequence 3, 5, 7, 11, 13, 17, 19, 23, 31, 41, 53, 59, 73, 107, 131, 167, 233, 239, 311, 877, 1277, 1283, 1427, 2393, 3581, 4547.

%o (Python)

%o from sympy import isprime, prime

%o from itertools import chain, combinations as C

%o def powerset(s): # skip empty set & singletons

%o return chain.from_iterable(C(s, r) for r in range(2, len(s)+1))

%o def a(n):

%o alst, next_set = [prime(i+1) for i in range(1, n)], {prime(n+1)}

%o while len(next_set):

%o alst.append(min(next_set)); next_set = set()

%o for s in powerset(alst[-n:]):

%o ss = sum(s)

%o if len(next_set):

%o if ss > min(next_set): continue

%o if ss > alst[-1]:

%o if isprime(ss): next_set.add(ss)

%o return len(alst) # return alst on a(11) for A338134

%o for n in range(1, 12):

%o print(a(n), end=", ") # _Michael S. Branicky_, Dec 17 2020

%Y Cf. A338134 (when n=11).

%K nonn,hard,more

%O 1,2

%A _Anthony Winkelspecht_, Oct 16 2020

%E a(14) from _Michael S. Branicky_, Dec 17 2020