A344093 a(n) is the smallest positive integer not already in the sequence such that a(n) + a(n-1) is the product of two distinct primes, with a(1) = 1.
1, 5, 9, 6, 4, 2, 8, 7, 3, 11, 10, 12, 14, 19, 15, 18, 16, 17, 21, 13, 20, 26, 25, 30, 27, 24, 22, 29, 28, 23, 32, 33, 36, 38, 31, 34, 35, 39, 43, 42, 40, 37, 45, 41, 44, 47, 46, 48, 58, 53, 62, 49, 57, 54, 52, 59, 56, 50, 61, 68, 51, 55, 60, 63, 66, 67, 74, 69, 64
Offset: 1
Keywords
Examples
a(4) = 6 because 6 is the smallest k such that a(3) + k is the product of two distinct primes.
Programs
-
Mathematica
a[1]=1;a[n_]:=a[n]=(k=1;While[MemberQ[Array[a,n-1],k]||Last/@FactorInteger[a[n-1]+k]!={1,1},k++];k);Array[a,100] (* Giorgos Kalogeropoulos, Aug 16 2021 *)
-
Python
terms = [1] previous = 1 def isValid(num): counter = 0 for possibleDiv in range(1, int(math.sqrt(num)) + 1): if num % possibleDiv == 0: counter += 1 if num/possibleDiv % possibleDiv == 0 and possibleDiv != 1: return False if counter > 2: return False if counter == 2: return True return False def generateSequence(numOfTerms): for i in range(numOfTerms): testNum = 1 valid = False while not valid: if testNum not in terms: possibleNum = previous + testNum if isValid(num): valid = True terms.append(testNum) previous = testNum testNum += 1
Comments