cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A377947 Unfriendly EKG sequence: a(1) = 1; a(2) = 3; for n > 2, a(n) = least number not already used which shares a factor with a(n-1) and is less than half or more than twice a(n-1).

This page as a plain text file.
%I A377947 #12 Nov 30 2024 13:01:29
%S A377947 1,3,9,21,6,2,8,18,4,10,22,46,12,26,54,14,30,5,15,33,11,44,16,34,70,7,
%T A377947 28,58,20,42,86,24,50,102,17,51,105,25,55,115,23,69,27,57,19,76,32,66,
%U A377947 134,36,74,150,35,75,153,39,13,52,106,38,78,158,40,82,166,48,98,198,45,93,31,124
%N A377947 Unfriendly EKG sequence: a(1) = 1; a(2) = 3; for n > 2, a(n) = least number not already used which shares a factor with a(n-1) and is less than half or more than twice a(n-1).
%F A377947 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)).
%e A377947 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.
%o A377947 (Python)
%o A377947 from math import gcd
%o A377947 from itertools import count, islice
%o A377947 def c(k, an): return gcd(k, an) > 1 and not an <= 2*k <= 4*an
%o A377947 def agen(): # generator of terms
%o A377947     yield 1
%o A377947     aset, an, m = {1}, 3, 2
%o A377947     while True:
%o A377947         yield an
%o A377947         aset.add(an)
%o A377947         an = next(k for k in count(m) if k not in aset and c(k, an))
%o A377947         while m in aset: m += 1
%o A377947 print(list(islice(agen(), 72))) # _Michael S. Branicky_, Nov 21 2024
%Y A377947 Cf. A064413.
%K A377947 nonn
%O A377947 1,2
%A A377947 _Will Nicholes_, Nov 11 2024