A098550 The Yellowstone permutation: a(n) = n if n <= 3, otherwise the smallest number not occurring earlier having at least one common factor with a(n-2), but none with a(n-1).
1, 2, 3, 4, 9, 8, 15, 14, 5, 6, 25, 12, 35, 16, 7, 10, 21, 20, 27, 22, 39, 11, 13, 33, 26, 45, 28, 51, 32, 17, 18, 85, 24, 55, 34, 65, 36, 91, 30, 49, 38, 63, 19, 42, 95, 44, 57, 40, 69, 50, 23, 48, 115, 52, 75, 46, 81, 56, 87, 62, 29, 31, 58, 93, 64, 99, 68, 77, 54, 119, 60
Offset: 1
Links
- Paul Tek, Table of n, a(n) for n = 1..10000
- David Applegate, C++ program for efficiently computing terms
- David Applegate, Revised C++ program with option to print more variables
- David L. Applegate, Hans Havermann, Bob Selcoe, Vladimir Shevelev, N. J. A. Sloane, and Reinhard Zumkeller, The Yellowstone Permutation, arXiv preprint arXiv:1501.01669 [math.NT], 2015. Also Journal of Integer Sequences, Vol. 18:6 (2015), Article 15.6.7
- Brady Haran and N. J. A. Sloane, The Yellowstone Permutation, Numberphile video, Jan 29 2023. [At 4:07 when I say "we got twice 61" I should have said "we got about twice 61", and the image should show 120 rather than 122.- _N. J. A. Sloane_, Feb 02 2023]
- Hans Havermann, Graph of first 300000 terms (the red line is y=x)
- Hans Havermann, Loops and unresolved chains for map n -> A098550(n) trajectories
- L. Edson Jeffery, Log plot of first 2484 terms.
- Dariel I. Ojera, Unveiling the Properties and Relationship of Yellowstone Permutation Sequence, Psych. Educ.: Multidisc. J. (2024) Vol. 27, No. 2, 173-184.
- Scott R. Shannon, Graph of 250000 terms, based on Reinhard Zumkeller data, plotted with colors indicating the least prime factor (lpf). Terms with an lpf of 2 are shown in white, terms with an lpf of 3,5,7,11,13,17,19 are shown as one of the seven rainbow colors from red to violet, and terms with an lpf >= 23 are shown in gray.
- N. J. A. Sloane, First 250000 terms sorted according to slope a(n)/n
- N. J. A. Sloane, Conant's Gasket, Recamán Variations, the Enots Wolley Sequence, and Stained Glass Windows, Experimental Math Seminar, Rutgers University, Sep 10 2020 (video of Zoom talk)
- N. J. A. Sloane, The OEIS: A Fingerprint File for Mathematics, arXiv:2105.05111 [math.HO], 2021.
- N. J. A. Sloane, "A Handbook of Integer Sequences" Fifty Years Later, arXiv:2301.03149 [math.NT], 2023, p. 16.
- Reinhard Zumkeller, Table of n, a(n) for n = 1..250000
- Index entries for sequences that are permutations of the natural numbers
Crossrefs
The inverse permutation is in A098551.
A098552(n) = a(a(n)).
A251102(n) = GCD(a(n+2),a(n)).
Cf. A251101 (smallest prime factor), A251103 (largest prime factor), A251138 (number of distinct prime factors), A251140 (total number of prime factors), A251045 (squarefree part), A251089 (squarefree kernel), A250127 and A251415 (records for a(n)/n), A251411 (fixed points), A248647 (records).
Cf. also A251412 (trajectory of 11), A251556 (finite cycles), A251413 and A251414 (variant involving odd numbers), A249357 ("Fibonacci" variant).
Smallest missing numbers: A251416, A251417, A251546-A251552, A247253. See also A251557, A241558, A251559.
Indices of some pertinent subsequences: A251237 (even numbers), A251238 (odd numbers), A251391 (squarefree), A251541 and A251239 (primes), A251240 (squares of primes), A251241 (prime powers), A251393 (powers of 2), A251392 (nonprimes), A253297 (primes p for which some multiple k*p > 2*p precedes p).
Two sequences related to the numbers which immediately follow a prime: A253048, A253049. Seven sequences related to the numbers that appear two steps after primes: A251542, A251543, A251544, A251545, A253052, A253053, A253054. See also A253055 and A253056.
See also A251756, A253297, A251662, A253572, A253573, A253591, A253593, A253588, A253590, A253609, A252865, A252867, A252868, A247225, A247942, A254003, A254077, A254669, A254670, A255509 (version with a priority for appearance of the primes), A255615, A255617, A256189, A256224, A256368, A256461.
See also A064413 (EKG sequence), A255582, A121216 (similar sequences), A257112 (two-dimensional analog).
See A336957 for a variation.
Programs
-
Haskell
import Data.List (delete) a098550 n = a098550_list !! (n-1) a098550_list = 1 : 2 : 3 : f 2 3 [4..] where f u v ws = g ws where g (x:xs) = if gcd x u > 1 && gcd x v == 1 then x : f v x (delete x ws) else g xs -- Reinhard Zumkeller, Nov 21 2014
-
Maple
N:= 10^4: # to get a(1) to a(n) where a(n+1) is the first term > N B:= Vector(N,datatype=integer[4]): for n from 1 to 3 do A[n]:= n: od: for n from 4 do for k from 4 to N do if B[k] = 0 and igcd(k,A[n-1]) = 1 and igcd(k,A[n-2]) > 1 then A[n]:= k; B[k]:= 1; break fi od: if k > N then break fi od: seq(A[i],i=1..n-1); # Robert Israel, Nov 21 2014
-
Mathematica
f[lst_List] := Block[{k = 4}, While[ GCD[ lst[[-2]], k] == 1 || GCD[ lst[[-1]], k] > 1 || MemberQ[lst, k], k++]; Append[lst, k]]; Nest[f, {1, 2, 3}, 68] (* Robert G. Wilson v, Nov 21 2014 *) NN = Range[4, 1000]; a098550 = {1, 2, 3}; g = {-1}; While[g[[1]] != 0, g = Flatten[{FirstPosition[NN, v_ /; GCD[a098550[[-1]], v] == 1 && GCD[a098550[[-2]], v] > 1, 0]}]; If[g[[1]] != 0, d = NN[[g]]; a098550 = Flatten[Append[a098550, d[[1]]]]; NN = Delete[NN, g[[1]]]]]; Table[a098550[[n]], {n, 71}] (* L. Edson Jeffery, Jan 01 2015 *)
-
PARI
a(n, show=1, a=3, o=2, u=[])={n<3&&return(n); show&&print1("1, 2"); for(i=4,n, show&&print1(","a); u=setunion(u, Set(a)); while(#u>1 && u[2]==u[1]+1, u=vecextract(u,"^1")); for(k=u[1]+1, 9e9, gcd(k,o)>1||next; setsearch(u,k)&&next; gcd(k,a)==1||next; o=a; a=k; break)); a} \\ Replace "show" by "a+1==i" in the main loop to print only fixed points. - M. F. Hasler, Dec 01 2014
-
Python
from math import gcd A098550_list, l1, l2, s, b = [1,2,3], 3, 2, 4, {} for _ in range(1,10**6): i = s while True: if not i in b and gcd(i,l1) == 1 and gcd(i,l2) > 1: A098550_list.append(i) l2, l1, b[i] = l1, i, 1 while s in b: b.pop(s) s += 1 break i += 1 # Chai Wah Wu, Dec 04 2014
Comments