OFFSET
1,2
FORMULA
a(n) = least number not already used such that gcd(a(n), a(n-1)) > 1 and ((a(n) < a(n-1) / 2) or (a(n) > a(n-1) * 2)).
EXAMPLE
a(3) = 9 since it is the least unused number that shares a factor with a(2) = 3 and is less than 3/2 or greater than 3*2.
PROG
(Python)
from math import gcd
from itertools import count, islice
def c(k, an): return gcd(k, an) > 1 and not an <= 2*k <= 4*an
def agen(): # generator of terms
yield 1
aset, an, m = {1}, 3, 2
while True:
yield an
aset.add(an)
an = next(k for k in count(m) if k not in aset and c(k, an))
while m in aset: m += 1
print(list(islice(agen(), 72))) # Michael S. Branicky, Nov 21 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Will Nicholes, Nov 11 2024
STATUS
approved