A373999 a(1) = 1, a(2) = 2, a(3) = 3, a(4) = 5, a(5) = 7; for n > 5, a(n) is the smallest unused positive number that is coprime to a(n-1), a(n-2) and a(n-3) but has a common factor with at least one of a(1)...a(n-4).
1, 2, 3, 5, 7, 4, 9, 25, 49, 8, 27, 55, 91, 16, 51, 11, 13, 10, 17, 21, 121, 20, 169, 57, 77, 32, 65, 19, 33, 14, 85, 247, 69, 22, 35, 221, 23, 6, 95, 119, 143, 12, 115, 133, 187, 18, 125, 161, 209, 24, 145, 217, 253, 26, 15, 29, 31, 28, 39, 185, 289, 38, 63, 37, 155, 34, 81, 203, 205, 44
Offset: 1
Keywords
Examples
a(9) = 49 as 49 is the smallest unused number that is coprime to a(6) = 4, a(7) = 9, and a(8) = 25, while sharing a factor with a(5) = 7.
Links
- Scott R. Shannon, Table of n, a(n) for n = 1..10000
- Scott R. Shannon, Image of the first 100000 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, 7] yield from alst aset, LCM, mink = set(alst), lcm(*alst[:-3]), 4 while True: an = next(k for k in count(mink) if k not in aset and all(1 == gcd(k, m) for m in alst[-3:]) and gcd(k, LCM) > 1) LCM = lcm(LCM, alst[-3]) alst.append(an) aset.add(an) while mink in aset: mink += 1 yield an print(list(islice(agen(), 70))) # Michael S. Branicky, Jun 24 2024
Comments