OFFSET
1,1
COMMENTS
For n >= 5, also the number of (undirected) Hamiltonian cycles in the (n-2)-Moebius ladder. - Eric W. Weisstein, May 06 2019
For n >= 4, also the number of (undirected) Hamiltonian cycles in the (n-1)-prism graph. - Eric W. Weisstein, May 06 2019
The lexicographically first involution of the natural numbers with no fixed points. - Alexander Fraebel, Sep 08 2020
LINKS
Eric Weisstein's World of Mathematics, Hamiltonian Cycle
Eric Weisstein's World of Mathematics, Moebius Ladder
Eric Weisstein's World of Mathematics, Prism Graph
Index entries for linear recurrences with constant coefficients, signature (1,1,-1).
FORMULA
O.g.f.: x*(x^2-x+2)/((x-1)^2*(1+x)). - R. J. Mathar, Apr 06 2008
a(n) = n-1+2*(n mod 2). - Rolf Pleisch, Apr 22 2008
a(n) = 2*n-a(n-1)-1 (with a(1)=2). - Vincenzo Librandi, Nov 16 2010
From Bruno Berselli, Nov 16 2010: (Start)
a(n) = n - (-1)^n.
a(n) - a(n-1) - a(n-2) + a(n-3) = 0 for n > 3.
(a(n) - 1)*(a(n-1) + 1) = 2*A176222(n+1) for n > 1.
(a(n) - 1)*(a(n-3) + 1) = 2*A176222(n) for n > 3. (End)
E.g.f.: 1 - exp(-x) + x*exp(x). - Stefano Spezia, May 03 2023
MATHEMATICA
Table[{n + 1, n}, {n, 1, 100, 2}] // Flatten
Table[n - (-1)^n, {n, 25}] (* Eric W. Weisstein, May 06 2019 *)
PROG
(Magma) [n eq 1 select 2 else -Self(n-1)+2*n-1: n in [1..72]];
(Haskell)
import Data.List (transpose)
a103889 n = n - 1 + 2 * mod n 2
a103889_list = concat $ transpose [tail a005843_list, a005408_list]
-- Reinhard Zumkeller, Jun 23 2013, Feb 21 2011
(PARI) a(n)=n-1+if(n%2, 2) \\ Charles R Greathouse IV, Feb 24 2011
(Python)
def a(n): return n+1 if n&1 else n-1
print([a(n) for n in range(1, 73)]) # Michael S. Branicky, May 03 2023
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Zak Seidov, Feb 20 2005
STATUS
approved