%I #23 Sep 02 2018 16:40:13
%S 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 19,66,95,46,55,23,65,69,70,57,58,93,29,31,87,62,105,74,77,37,110,111,
%U 82,129,41,43,123,86,141,106,47,53,94,159,118,165,59,78,295
%N 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 Similar to A098550, but the restriction to squarefree makes it more a sequence of sets of primes, represented by their product.
%C 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 Reinhard Zumkeller, <a href="/A252865/b252865.txt">Table of n, a(n) for n = 1..10000</a>
%H 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 a[n_ /; n <= 3] = n;
%t 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 Array[a, 100] (* _Jean-François Alcover_, Sep 02 2018 *)
%o (PARI) invecn(v, k, x)=for(i=1, k, if(v[i]==x, return(i))); 0
%o 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 (Haskell)
%o import Data.List (delete)
%o a252865 n = a252865_list !! (n-1)
%o a252865_list = 1 : 2 : 3 : f 2 3 (drop 3 a005117_list) where
%o f u v ws = g ws where
%o g (x:xs) = if gcd x u > 1 && gcd x v == 1
%o then x : f v x (delete x ws) else g xs
%o -- _Reinhard Zumkeller_, Dec 24 2014
%o (Python)
%o from fractions import gcd
%o from sympy import factorint
%o A252865_list, l1, l2, s, b = [1,2,3], 3, 2, 4, set()
%o for _ in range(10**2):
%o ....i = s
%o ....while True:
%o ........if max(factorint(i).values()) == 1:
%o ............if not i in b and gcd(i,l1) == 1 and gcd(i,l2) > 1:
%o ................A252865_list.append(i)
%o ................l2, l1 = l1, i
%o ................b.add(i)
%o ................while s in b:
%o ....................b.remove(s)
%o ....................s += 1
%o ................break
%o ........else:
%o ............b.add(i)
%o ........i += 1 # _Chai Wah Wu_, Dec 24 2014
%Y Cf. A098550, A005117, A252867, A252868.
%Y Cf. A251391.
%K nonn
%O 1,2
%A _Franklin T. Adams-Watters_, Dec 23 2014
|