A352187 a(1)=1, a(2)=2; thereafter, a(n) is the smallest number m not yet in the sequence such that gcd(m,a(n-1)) > 1 and gcd(m,a(n-2))=1, except that the second condition is ignored if it would imply that no choice for m were possible.
1, 2, 4, 6, 3, 9, 12, 8, 10, 5, 15, 18, 14, 7, 21, 24, 16, 20, 25, 30, 22, 11, 33, 27, 36, 26, 13, 39, 42, 28, 32, 34, 17, 51, 45, 35, 49, 56, 38, 19, 57, 48, 40, 55, 77, 63, 54, 44, 121, 66, 46, 23, 69, 60, 50, 52, 91, 105, 72, 58, 29, 87, 75, 65, 104, 62, 31, 93, 78, 64, 68, 85, 95, 76, 74, 37, 111, 81, 84, 70, 115, 207, 96, 80
Offset: 1
Keywords
Links
- N. J. A. Sloane, Table of n, a(n) for n = 1..20000
Crossrefs
Programs
-
Maple
# To produce the first 1000 terms: with(numtheory): omega := proc(n) nops(numtheory[factorset](n)) end proc: hit:=Array(1..100000,0); M:=100000; a:=[1,2]; K:=1; L:=2; hit[1]:=1; hit[2]:=2; for n from 3 to 1000 do sw1:=0; # find a[n] if factorset(L) subset factorset(K) then # use EKG rule for i from 1 to M do if hit[i]=0 and igcd(i,L)>1 then a:=[op(a),i]; K:=L; L:=i; hit[i]:=n; sw1:=1; break; fi; od: if sw1=0 then error("failed EKG, n, i =", n,i); fi; else # use Enots Wolley rule for i from 1 to M do if hit[i]=0 and igcd(i,L)>1 and igcd(i,K)=1 then a:=[op(a),i]; K:=L; L:=i; hit[i]:=n; sw1:=1; break; fi; od: if sw1=0 then error("failed WOLLEY, n, i =", n,i); fi; fi: od: a;
-
Python
from math import gcd from itertools import count, islice from sympy import primefactors def A352187_gen(): # generator of terms bset, blist, mmax = {1,2}, [1,2], 3 yield from blist while True: for m in count(mmax): if gcd(m,blist[-1]) > 1 and m not in bset: if all(blist[-2] % p == 0 for p in primefactors(blist[-1])) or gcd(m,blist[-2]) == 1: yield m blist = [blist[-1],m] bset.add(m) while mmax in bset: mmax += 1 break A352187_list = list(islice(A352187_gen(),20)) # Chai Wah Wu, Mar 14 2022
Comments