A373998 a(1) = 1, a(2) = 2, a(3) = 3, a(4) = 5; for n > 4, a(n) is the smallest unused positive number that is coprime to a(n-1) and a(n-2) but has a common factor with at least one of a(1)...a(n-3).
1, 2, 3, 5, 4, 9, 25, 8, 21, 55, 16, 7, 11, 6, 35, 121, 12, 49, 65, 18, 77, 13, 10, 27, 91, 20, 33, 119, 26, 15, 17, 14, 39, 85, 22, 57, 115, 28, 19, 23, 24, 95, 143, 32, 45, 133, 34, 69, 125, 38, 51, 145, 44, 63, 29, 40, 81, 161, 50, 87, 169, 46, 75, 187, 52, 93, 175, 58, 31, 99, 56, 155
Offset: 1
Keywords
Examples
a(7) = 25 as 25 is the smallest unused number that is coprime to a(5) = 4 and a(6) = 9 while sharing a factor with a(4) = 5.
Links
- Scott R. Shannon, Table of n, a(n) for n = 1..10000
- Scott R. Shannon, Image of the first 50000 terms. Numbers with one, two, three, four, or five and more prime factors, counted with multiplicity, are show as red, yellow, green, blue and violet respectively.
Programs
-
Python
from math import gcd, lcm from itertools import count, islice def agen(): # generator of terms alst = [1, 2, 3, 5] yield from alst aset, LCM, mink = set(alst), lcm(*alst[:-2]), 4 while True: an = next(k for k in count(mink) if k not in aset and 1 == gcd(k, alst[-1]) == gcd(k, alst[-2]) and gcd(k, LCM) > 1) LCM = lcm(LCM, alst[-2]) alst.append(an) aset.add(an) while mink in aset: mink += 1 yield an print(list(islice(agen(), 72))) # Michael S. Branicky, Jun 24 2024
Comments