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.
%I A251554 #31 Jan 26 2025 09:12:05 %S A251554 1,2,5,4,15,8,3,10,9,14,27,7,6,35,12,25,16,45,22,21,11,18,55,24,65,28, %T A251554 13,20,39,32,33,26,51,38,17,19,34,57,40,63,44,49,30,77,36,91,46,105, %U A251554 23,42,115,48,85,52,75,56,69,50,81,58,93,29,31,87,62,99,64,111 %N A251554 a(1)=1, a(2)=2, a(3)=5; thereafter a(n) is the smallest number not occurring earlier having at least one common factor with a(n-2), but none with a(n-1). %C A251554 A variant of A098550. See that entry for much more information. %C A251554 It seems likely that this sequence will never merge with A098550, but it would be nice to have a proof. %H A251554 Chai Wah Wu, <a href="/A251554/b251554.txt">Table of n, a(n) for n = 1..10000</a> %H A251554 David L. Applegate, Hans Havermann, Bob Selcoe, Vladimir Shevelev, N. J. A. Sloane, and Reinhard Zumkeller, <a href="http://arxiv.org/abs/1501.01669">The Yellowstone Permutation</a>, arXiv preprint arXiv:1501.01669, 2015 and <a href="https://cs.uwaterloo.ca/journals/JIS/VOL18/Sloane/sloane9.html">J. Int. Seq. 18 (2015) 15.6.7</a>. %t A251554 a251554[lst_List] := %t A251554 Block[{k = 3}, %t A251554 While[GCD[lst[[-2]], k] == 1 || GCD[lst[[-1]], k] > 1 || %t A251554 MemberQ[lst, k], k++]; Append[lst, k]]; Nest[a251554, {1, 2, %t A251554 5}, 120] (* _Michael De Vlieger_, Dec 23 2014, after _Robert G. Wilson v_ at A098550 *) %o A251554 (Python) %o A251554 from math import gcd %o A251554 A251554_list, l1, l2, s, b = [1,2,5], 5, 2, 3, {5} %o A251554 for _ in range(10**4): %o A251554 i = s %o A251554 while True: %o A251554 if not i in b and gcd(i,l1) == 1 and gcd(i,l2) > 1: %o A251554 A251554_list.append(i) %o A251554 l2, l1 = l1, i %o A251554 b.add(i) %o A251554 while s in b: %o A251554 b.remove(s) %o A251554 s += 1 %o A251554 break %o A251554 i += 1 # _Chai Wah Wu_, Dec 21 2014 %o A251554 (Haskell) %o A251554 import Data.List (delete) %o A251554 a251554 n = a251554_list !! (n-1) %o A251554 a251554_list = 1 : 2 : 5 : f 2 5 (3 : 4 : [6..]) where %o A251554 f u v ws = g ws where %o A251554 g (x:xs) = if gcd x u > 1 && gcd x v == 1 %o A251554 then x : f v x (delete x ws) else g xs %o A251554 -- _Reinhard Zumkeller_, Dec 26 2014 %Y A251554 Cf. A098550, A251555. %K A251554 nonn %O A251554 1,2 %A A251554 _N. J. A. Sloane_, Dec 21 2014