This site is supported by donations to The OEIS Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A065190 Self-inverse permutation of natural numbers: 1 is fixed, followed by infinite number of adjacent transpositions (n n+1). 15

%I

%S 1,3,2,5,4,7,6,9,8,11,10,13,12,15,14,17,16,19,18,21,20,23,22,25,24,27,

%T 26,29,28,31,30,33,32,35,34,37,36,39,38,41,40,43,42,45,44,47,46,49,48,

%U 51,50,53,52,55,54,57,56,59,58,61,60,63,62,65,64,67,66,69,68,71,70,73

%N Self-inverse permutation of natural numbers: 1 is fixed, followed by infinite number of adjacent transpositions (n n+1).

%C Also, a lexicographically minimal sequence of distinct positive integers such that a(n) is coprime to n. - _Ivan Neretin_, Apr 18 2015

%C The larger term of the pair [a(n), a(n+1)] is always odd. Had we started the sequence with a(1) = 0, it would be the lexicographically first sequence with this property if always extented with the smallest integer not yet present. - _Eric Angelini_, Feb 17 2017

%C From _Yosu Yurramendi_, Mar 21 2017: (Start)

%C This sequence is self-inverse. Except for the fixed point 1, it consists completely of 2-cycles: (2n, 2n+1), n > 0.

%C A020651(a(n)) = A020650(n), A020650(a(n)) = A020651(n), n > 0.

%C A245327(a(n)) = A245328(n), A245328(a(n)) = A245327(n), n > 0.

%C A063946(a(n)) = a(A063946(n)), n > 0.

%C A054429(a(n)) = a(A054429(n)) = A092569(n), n > 0.

%C A258996(a(n)) = a(A258996(n)), n > 0.

%C A258746(a(n)) = a(A258746(n)), n > 0. (End)

%C From _Enrique Navarrete_, Nov 13 2017: (Start)

%C With a(0)=0, and the rest of the sequence appended, a(n) is the smallest positive number not yet in the sequence such that the arithmetic mean of the first n+1 terms a(0), a(1), ..., a(n) is not an integer; i.e., the sequence is 0, 1, 3, 2, 5, 4, 7, 6, 9, 8, ...

%C Example: for n=5, (0 + 1 + 3 + 2 + 5)/5 is not an integer.

%C Fixed points are odd numbers >= 3 and also a(n) = n-2 for even n >= 4. (End)

%H Harry J. Smith, <a href="/A065190/b065190.txt">Table of n, a(n) for n = 1..1000</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (1,1,-1).

%F a(1) = 1, a(n) = n+(-1)^n.

%F From _Colin Barker_, Feb 18 2013: (Start)

%F a(n) = a(n-1) + a(n-2) - a(n-3) for n>4.

%F G.f.: x*(x^3 - 2*x^2 + 2*x + 1) / ((x-1)^2*(x+1)). (End)

%F a(n)^a(n) == 1 (mod n). - _Thomas Ordowski_, Jan 04 2016

%F E.g.f.: x*(1+exp(x)) - 1 + exp(-x). - _Robert Israel_, Feb 04 2016

%F a(n) = A014681(n-1) + 1. - _Michel Marcus_, Dec 10 2016

%p [seq(f(j),j=1..120)]; f := (n) -> `if`((n < 2), n,n+((-1)^n));

%t f[n_] := Rest@ Flatten@ Transpose[{Range[1, n + 1, 2], {1}~Join~Range[2, n, 2]}]; f@ 72 (* _Michael De Vlieger_, Apr 18 2015 *)

%t Rest@ CoefficientList[Series[x (x^3 - 2 x^2 + 2 x + 1)/((x - 1)^2*(x + 1)), {x, 0, 72}], x] (* _Michael De Vlieger_, Feb 17 2017 *)

%o (PARI) { for (n=1, 1000, if (n>1, a=n + (-1)^n, a=1); write("b065190.txt", n, " ", a) ) } \\ _Harry J. Smith_, Oct 13 2009

%o (PARI) x='x+O('x^100); Vec(x*(x^3-2*x^2+2*x+1)/((x-1)^2*(x+1))) \\ _Altug Alkan_, Feb 04 2016

%o (MAGMA) [1] cat [n+(-1)^n: n in [2..80]]; // _Vincenzo Librandi_, Apr 18 2015

%o (Python) def a(n): return 1 if n<2 else n + (-1)**n # _Indranil Ghosh_, Mar 22 2017

%o (R)

%o maxrow <- 8 # by choice

%o a <- c(1,3,2) # If it were c(1,2,3), it would be A000027

%o for(m in 1:maxrow) for(k in 0:(2^m-1)){

%o a[2^(m+1)+ k] = a[2^m+k] + 2^m

%o a[2^(m+1)+2^m+k] = a[2^m+k] + 2^(m+1)

%o }

%o a

%o # _Yosu Yurramendi_, Apr 10 2017

%Y Cf. A004442, A065190 o A014681 = A065168, A014681 o A065190 = A065164.

%K nonn,easy

%O 1,2

%A _Antti Karttunen_, Oct 19 2001

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified February 21 15:34 EST 2019. Contains 320374 sequences. (Running on oeis4.)