

A065190


Selfinverse permutation of natural numbers: 1 is fixed, followed by infinite number of adjacent transpositions (n n+1).


15



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, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41, 40, 43, 42, 45, 44, 47, 46, 49, 48, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 63, 62, 65, 64, 67, 66, 69, 68, 71, 70, 73
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,2


COMMENTS

Also, a lexicographically minimal sequence of distinct positive integers such that a(n) is coprime to n.  Ivan Neretin, Apr 18 2015
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
From Yosu Yurramendi, Mar 21 2017: (Start)
This sequence is selfinverse. Except for the fixed point 1, it consists completely of 2cycles: (2n, 2n+1), n > 0.
A020651(a(n)) = A020650(n), A020650(a(n)) = A020651(n), n > 0.
A245327(a(n)) = A245328(n), A245328(a(n)) = A245327(n), n > 0.
A063946(a(n)) = a(A063946(n)), n > 0.
A054429(a(n)) = a(A054429(n)) = A092569(n), n > 0.
A258996(a(n)) = a(A258996(n)), n > 0.
A258746(a(n)) = a(A258746(n)), n > 0. (End)
From Enrique Navarrete, Nov 13 2017: (Start)
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, ...
Example: for n=5, (0 + 1 + 3 + 2 + 5)/5 is not an integer.
Fixed points are odd numbers >= 3 and also a(n) = n2 for even n >= 4. (End)


LINKS

Harry J. Smith, Table of n, a(n) for n = 1..1000
Index entries for sequences that are permutations of the natural numbers
Index entries for linear recurrences with constant coefficients, signature (1,1,1).


FORMULA

a(1) = 1, a(n) = n+(1)^n.
From Colin Barker, Feb 18 2013: (Start)
a(n) = a(n1) + a(n2)  a(n3) for n>4.
G.f.: x*(x^3  2*x^2 + 2*x + 1) / ((x1)^2*(x+1)). (End)
a(n)^a(n) == 1 (mod n).  Thomas Ordowski, Jan 04 2016
E.g.f.: x*(1+exp(x))  1 + exp(x).  Robert Israel, Feb 04 2016
a(n) = A014681(n1) + 1.  Michel Marcus, Dec 10 2016


MAPLE

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


MATHEMATICA

f[n_] := Rest@ Flatten@ Transpose[{Range[1, n + 1, 2], {1}~Join~Range[2, n, 2]}]; f@ 72 (* Michael De Vlieger, Apr 18 2015 *)
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 *)


PROG

(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
(PARI) x='x+O('x^100); Vec(x*(x^32*x^2+2*x+1)/((x1)^2*(x+1))) \\ Altug Alkan, Feb 04 2016
(MAGMA) [1] cat [n+(1)^n: n in [2..80]]; // Vincenzo Librandi, Apr 18 2015
(Python) def a(n): return 1 if n<2 else n + (1)**n # Indranil Ghosh, Mar 22 2017
(R)
maxrow < 8 # by choice
a < c(1, 3, 2) # If it were c(1, 2, 3), it would be A000027
for(m in 1:maxrow) for(k in 0:(2^m1)){
a[2^(m+1)+ k] = a[2^m+k] + 2^m
a[2^(m+1)+2^m+k] = a[2^m+k] + 2^(m+1)
}
a
# Yosu Yurramendi, Apr 10 2017


CROSSREFS

Cf. A004442, A065190 o A014681 = A065168, A014681 o A065190 = A065164.
Sequence in context: A114882 A306436 A004442 * A152208 A282650 A270671
Adjacent sequences: A065187 A065188 A065189 * A065191 A065192 A065193


KEYWORD

nonn,easy


AUTHOR

Antti Karttunen, Oct 19 2001


STATUS

approved



