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.

A252865 a(n) = n if n <= 3, otherwise the smallest squarefree number not occurring earlier having at least one common factor with a(n-2), but none with a(n-1).

This page as a plain text file.
%I A252865 #30 Jan 29 2025 13:09:52
%S A252865 1,2,3,10,21,5,6,35,22,7,11,14,33,26,15,13,30,91,34,39,17,42,85,38,51,
%T A252865 19,66,95,46,55,23,65,69,70,57,58,93,29,31,87,62,105,74,77,37,110,111,
%U A252865 82,129,41,43,123,86,141,106,47,53,94,159,118,165,59,78,295
%N A252865 a(n) = n if n <= 3, otherwise the smallest squarefree number not occurring earlier having at least one common factor with a(n-2), but none with a(n-1).
%C A252865 Similar to A098550, but the restriction to squarefree makes it more a sequence of sets of primes, represented by their product.
%C A252865 The sequence has consecutive primes at indices 2 (2 & 3), 10 (7 & 11), 38 (29 & 31), 50 (41 & 43), and 56 (47 & 53). We conjecture that there are no further such pairs.
%H A252865 Reinhard Zumkeller, <a href="/A252865/b252865.txt">Table of n, a(n) for n = 1..10000</a>
%H A252865 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 A252865 a[n_ /; n <= 3] = n;
%t A252865 a[n_] := a[n] = For[k = 1, True, k++, If[SquareFreeQ[k], If[FreeQ[Array[a, n-1], k], If[!CoprimeQ[k, a[n-2]] && CoprimeQ[k, a[n-1]], Return[k]]]]];
%t A252865 Array[a, 100] (* _Jean-François Alcover_, Sep 02 2018 *)
%o A252865 (PARI) invecn(v, k, x)=for(i=1, k, if(v[i]==x, return(i))); 0
%o A252865 alist(n)=local(v=vector(n,i,i), x); for(k=4, n, x=4; while(!issquarefree(x)||invecn(v, k-1, x)||gcd(v[k-2], x)==1||gcd(v[k-1],x)!=1, x++); v[k]=x); v
%o A252865 (Haskell)
%o A252865 import Data.List (delete)
%o A252865 a252865 n = a252865_list !! (n-1)
%o A252865 a252865_list = 1 : 2 : 3 : f 2 3 (drop 3 a005117_list) where
%o A252865    f u v ws = g ws where
%o A252865      g (x:xs) = if gcd x u > 1 && gcd x v == 1
%o A252865                    then x : f v x (delete x ws) else g xs
%o A252865 -- _Reinhard Zumkeller_, Dec 24 2014
%o A252865 (Python)
%o A252865 from math import gcd
%o A252865 from sympy import factorint
%o A252865 A252865_list, l1, l2, s, b = [1,2,3], 3, 2, 4, set()
%o A252865 for _ in range(10**2):
%o A252865     i = s
%o A252865     while True:
%o A252865         if max(factorint(i).values()) == 1:
%o A252865             if not i in b and gcd(i,l1) == 1 and gcd(i,l2) > 1:
%o A252865                 A252865_list.append(i)
%o A252865                 l2, l1 = l1, i
%o A252865                 b.add(i)
%o A252865                 while s in b:
%o A252865                     b.remove(s)
%o A252865                     s += 1
%o A252865                 break
%o A252865         else:
%o A252865             b.add(i)
%o A252865         i += 1 # _Chai Wah Wu_, Dec 24 2014
%o A252865 (Python)
%o A252865 from math import gcd
%o A252865 from sympy import factorint
%o A252865 from itertools import count, islice
%o A252865 def issquarefree(n): return max(factorint(n).values()) == 1
%o A252865 def agen(): # generator of terms
%o A252865     aset, an2, an1, m = {1, 2, 3}, 2, 3, 4
%o A252865     yield from sorted(aset)
%o A252865     while True:
%o A252865         an = next(k for k in count(m) if k not in aset and gcd(k, an2) > 1 and gcd(k, an1) == 1 and issquarefree(k))
%o A252865         an2, an1 = an1, an
%o A252865         while m in aset or not issquarefree(m): m += 1
%o A252865         aset.add(an)
%o A252865         yield an
%o A252865 print(list(islice(agen(), 64))) # _Michael S. Branicky_, Jan 10 2025
%Y A252865 Cf. A098550, A005117, A251391, A252867, A252868.
%K A252865 nonn
%O A252865 1,2
%A A252865 _Franklin T. Adams-Watters_, Dec 23 2014