OFFSET
1,3
COMMENTS
Multiplicative with a(2^e)=0 if e>0 and a(p^e)=p^e for odd primes p. - R. J. Mathar, Aug 01 2011
A005408 and A000004 interleaved (the usual OEIS policy is not to include sequences like this where alternate terms are zero; this is an exception). - Omar E. Pol, Feb 02 2013
Row sums of A057211. - Omar E. Pol, Mar 05 2014
Column k=2 of triangle A196020. - Omar E. Pol, Aug 07 2015
a(n) is the determinant of the (n+2) X (n+2) circulant matrix with the first row [0,0,1,1,...,1]. This matrix is closely linked with the famous ménage problem (see also comments of Vladimir Shevelev in sequence A000179). Namely it defines the class of permutations p of 1,2,...,n+2 such that p(i)<>i and p(i)<>i+1 for i=1,2,...,n+1, and p(n+2)<>1,n+2. And a(n) is also the difference between the number of even and odd such permutations. - Dmitry Efimov, Feb 02 2016
REFERENCES
Franz Lemmermeyer, Reciprocity Laws. From Euler to Eisenstein, Springer, 2000, p. 237, eq. (8.5).
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 1..1000
C. Kravvaritis, Determinant evaluations for binary circulant matrices, Special Matrices, V2(1) (2014), 187-199.
Index entries for linear recurrences with constant coefficients, signature (0,2,0,-1).
FORMULA
a(n) = n^k mod 2n, for any k>=2, also for k=n.
Dirichlet g.f.: (1-2^(1-s))*zeta(s-1). - R. J. Mathar, Aug 01 2011
G.f.: x*(1+x^2)/(1-x^2)^2. - Philippe Deléham, Feb 13 2012
a(n) = n * (n mod 2). - Wesley Ivan Hurt, Jun 29 2013
G.f.: Sum_{n >= 1} A000010(n)*x^n/(1 + x^n). - Mircea Merca, Feb 22 2014
a(n) = 2*a(n-2)-a(n-4), for n>4. - Wesley Ivan Hurt, Aug 07 2015
E.g.f.: x*cosh(x). - Robert Israel, Feb 03 2016
a(n) = Product_{k=1..floor(n/2)}(sin(2*Pi*k/n))^2, for n >= 1 (with the empty product put to 1). Trivial for even n from the factor 0 for k = n/2. For odd n see, e.g., the Lemmermeyer reference, eq. (8.5) on p. 237. - Wolfdieter Lang, Aug 29 2016
a(n) = Sum_{k=1..n} (-1)^((n-k)*k). - Rick L. Shepherd, Sep 18 2020
a(n) = Sum_{k = 1..n} (-1)^(1+gcd(k,n)) = Sum_{d | n} (-1)^(d+1)*phi(n/d), where phi(n) = A000010(n). - Peter Bala, Jan 14 2024
MAPLE
MATHEMATICA
Table[PowerMod[n, n, 2*n], {n, 200}]
PROG
(PARI) a(n)=if(n%2, n) \\ Charles R Greathouse IV, Jul 24 2011
(Magma) I:=[1, 0, 3, 0]; [n le 4 select I[n] else 2*Self(n-2)-Self(n-4): n in [1..80]]; // Vincenzo Librandi, Feb 24 2014
CROSSREFS
KEYWORD
nonn,easy,mult
AUTHOR
José María Grau Ribas, Jul 24 2011
EXTENSIONS
Formula for a(n) extended by Wolfdieter Lang, Dec 21 2011
STATUS
approved