login
Lexicographically earliest sequence of distinct positive composite integers such that no subsequence sums to a prime and in which all terms are coprime.
0

%I #27 Apr 11 2023 12:06:20

%S 4,21,65,209,391,3149,9991,368131,57556589,14865154981

%N Lexicographically earliest sequence of distinct positive composite integers such that no subsequence sums to a prime and in which all terms are coprime.

%C The sequences A052349 and A068638 are composed of integers starting from one with the rule that no subsequence has a prime sum; these sequences start with one. Starting with a different number seems to result in straightforward geometric sequences, for example the sequence with no prime subsequence sums starting with four is 4, 6, 8, and so on. One way to avoid this is to enforce a coprime rule, requiring that the entries to the sequence are coprime. It is not clear whether the sequence is infinite.

%t k = 4; K = {k}; f = {2}; q = Subsets[K]; While[Length@K < 10, k++; If[! PrimeQ[k] && ! IntersectingQ[FactorInteger[k][[All, 1]], f], s = k; z = 0; For[p = 1, p <= Length@q, p++, If[PrimeQ[Total[q[[p]]] + k], z = 1; Break[]]]; If[z == 0, AppendTo[K, k]; q = Subsets[K]; AppendTo[f, FactorInteger[k][[All, 1]]]; f = Flatten[f]]]]; Print[K] (* _Samuel Harkness_, Apr 11 2023 *)

%o (Python)

%o import sys

%o import math

%o from sympy.ntheory import primefactors

%o from sympy.ntheory import primerange

%o def intersection(lst1, lst2):

%o lst3 = [value for value in lst1 if value in lst2]

%o return len(lst3)

%o n_primes=1000000

%o factors=[primefactors(n) for n in range(0,n_primes)]

%o primes=list(primerange(0, n_primes))

%o sequence=[4]

%o sums=[sequence[0]]

%o prime_factors=[f for f in factors[sequence[0]]]

%o big_n=8

%o while len(sequence)<big_n:

%o new_a=False

%o a=sequence[-1]+1

%o while intersection(factors[a],prime_factors)!=0:

%o a+=1

%o n=len(sequence)

%o while not new_a:

%o new_sum=[a+sum for sum in sums]

%o prime_sum=False

%o for sum in new_sum:

%o if sum in primes:

%o prime_sum=True

%o if not prime_sum and a not in primes:

%o sequence.append(a)

%o print(a,end=",")

%o sys.stdout.flush()

%o sums=sums+new_sum+[a]

%o sums = list(dict.fromkeys(sums))

%o prime_factors=prime_factors+factors[a]

%o new_a=True

%o else:

%o a+=1

%o while a in primes or intersection(factors[a],prime_factors)!=0:

%o a+=1

%o print()

%o (Python)

%o from math import gcd

%o from sympy import isprime

%o from itertools import islice

%o def agen(start=4): # generator of terms

%o alst, k, sums = [start], start+1, {0} | {start}

%o while True:

%o yield alst[-1]

%o while any(gcd(k, an) != 1 for an in alst) or \

%o any(k+s not in sums and isprime(k+s) for s in sums):

%o k += 1

%o alst.append(k)

%o sums.update([k + s for s in sums])

%o k += 1

%o print(list(islice(agen(), 8))) # _Michael S. Branicky_, Dec 16 2022

%Y Cf. A052349, A068638.

%K nonn,more

%O 1,1

%A _Conor Houghton_, Dec 15 2022

%E a(8)-a(9) from _Michael S. Branicky_, Dec 15 2022

%E a(10) from _Rémy Sigrist_, Dec 16 2022