A001057 Canonical enumeration of integers: interleaved positive and negative integers with zero prepended.
0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31
Offset: 0
Examples
G.f. = x - x^2 + 2*x^3 - 2*x^4 + 3*x^5 - 3*x^6 + 4*x^7 - 4*x^8 + 5*x^9 - 5*x^10 + ...
Links
- T. D. Noe, Table of n, a(n) for n = 0..1000
- D. Efimov, Determinants of generalized binary band matrices, arXiv:1702.05655 [math.RA], 2017.
- G. Myerson and A. J. van der Poorten, Some problems concerning recurrence sequences, Amer. Math. Monthly 102 (1995), no. 8, 698-705.
- Omar E. Pol, Illustration of initial terms of A001057, A005132, A000217
- Wikipedia, 1 - 2 + 3 - 4 + ...
- Index entries for linear recurrences with constant coefficients, signature (-1,1,1).
Crossrefs
Programs
-
Haskell
a001057 n = (n' + m) * (-1) ^ (1 - m) where (n',m) = divMod n 2 a001057_list = 0 : concatMap (\x -> [x,-x]) [1..] -- Reinhard Zumkeller, Apr 02 2012
-
Maple
a := n -> (1-(-1)^n*(2*n+1))/4; # Peter Luschny, Jul 12 2009
-
Mathematica
Join[{0},Riffle[Range[35],-Range[35]]] (* Harvey P. Dale, Sep 21 2011 *) a[ n_] := -(-1)^n Ceiling[n/2]; (* Michael Somos, Jun 05 2013 *) LinearRecurrence[{-1, 1, 1}, {0, 1, -1}, 63] (* Jean-François Alcover, Jan 07 2019 *)
-
PARI
{a(n) = if( n%2, n\2 + 1, -n/2)}; /* Michael Somos, Jul 20 1999 */
-
Python
def a(n): return n//2 + 1 if n%2 else -n//2 print([a(n) for n in range(63)]) # Michael S. Branicky, Jul 14 2022
Formula
Euler transform of [-1, 2] is sequence a(n+1). - Michael Somos, Jun 11 2003
G.f.: x / ((1 + x) * (1 - x^2)). - Michael Somos, Jul 20 1999
E.g.f.: (exp(x) - (1 - 2*x) * exp(-x)) / 4. - Michael Somos, Jun 11 2003
a(n) = 1 - 2*a(n-1) -a(n-2); a(2*n) = -n, a(2*n+1) = n+1. - Michael Somos, Jul 20 1999
a(n) = -a(n-1) + a(n-2) + a(n-3). a(n) = (-1)^(n+1) * floor((n+1) / 2). - Michael Somos, Jun 11 2003
a(1) = 1, a(n) = a(n-1)+n or a(n-1)-n whichever is closer to 0 on the number line. Or abs(a(n)) = min{abs(a(n-1)+n), abs(a(n-1)-n)}. - Amarnath Murthy, Jul 01 2003
a(n) = Sum_{k=0..n} k*(-1)^(k+1). - Paul Barry, Aug 20 2003
a(n) = (1-(2n+1)*(-1)^n)/4. - Paul Barry, Feb 02 2004
a(0) = 0; a(n) = (-1)^(n-1) * (n-|a(n-1)|) for n >= 1. - Rick L. Shepherd, Jul 14 2004
a(n) = a(n-1)-n*(-1)^n, a(0)=0; or a(n) = -a(n-1)+(1-(-1)^n)/2, a(0)=0. - Daniele Parisse and Franco Virga, Jun 06 2005
a(n) = ceiling(n/2) * (-1)^(n+1), n >= 0. - Franklin T. Adams-Watters, Nov 25 2011 (corrected by Daniel Forgues, Jul 21 2012)
a(n) = a(-1-n) for all n in Z. - Michael Somos, Jun 05 2013
Sum_{n>=1} 1/a(n) = 0. - Jaume Oliver Lafont, Jul 14 2017
Extensions
Thanks to Michael Somos for helpful comments.
Name edited by Franklin T. Adams-Watters, Jan 30 2012
Comments