login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A121216
a(1)=1, a(2) = 2; thereafter a(n) = the smallest positive integer which does not occur earlier in the sequence and which is coprime to a(n-2).
24
1, 2, 3, 5, 4, 6, 7, 11, 8, 9, 13, 10, 12, 17, 19, 14, 15, 23, 16, 18, 21, 25, 20, 22, 27, 29, 26, 24, 31, 35, 28, 32, 33, 37, 34, 30, 39, 41, 38, 36, 43, 47, 40, 42, 49, 53, 44, 45, 51, 46, 50, 55, 57, 48, 52, 59, 61, 54, 56, 65, 67, 58, 60, 63, 71, 62, 64, 69, 73, 68, 66, 75
OFFSET
1,2
COMMENTS
Permutation of the positive natural numbers with inverse A225047: a(A225047(n)) = A225047(a(n)) = n. - Reinhard Zumkeller, Apr 25 2013
I confirm that this is a permutation. - N. J. A. Sloane, Mar 28 2015 [This can be proved using an argument similar to (but simpler than) the proof in A093714. - N. J. A. Sloane, May 05 2022]
MATHEMATICA
Nest[Append[#, Block[{k = 3}, While[Nand[FreeQ[#, k], GCD[#[[-2]], k] == 1], k++]; k]] &, {1, 2}, 70] (* Michael De Vlieger, Dec 26 2019 *)
PROG
(Haskell)
import Data.List (delete, (\\))
a121216 n = a121216_list !! (n-1)
a121216_list = 1 : 2 : f 1 2 [3..] where
f x y zs = g zs where
g (u:us) = if gcd x u == 1 then h $ delete u zs else g us where
h (v:vs) = if gcd y v == 1 then u : v : f u v (zs \\ [u, v]) else h vs
-- Reinhard Zumkeller, Apr 25 2013
CROSSREFS
KEYWORD
nonn
AUTHOR
Leroy Quet, Aug 20 2006
EXTENSIONS
Extended by Ray Chandler, Aug 22 2006
STATUS
approved