This is the Grandi's series: $1-1+1-1+1-1+\dots$

The series can be equal to $0$

$$(1-1)+(1-1)+(1-1)+\dots=0+0+0+\dots=0,$$

or to $1$

$$1-(1-1)-(1-1)-(1-1)-\dots=1-0-0-0\dots=1,$$

or to $1/2$

$$S=1-1+1-1+1-\dots,\quad\quad S=1-(1-1+1-1+1-1+1-...)$$ $$\Rightarrow S=1-S\Rightarrow 2S=1\Rightarrow S=1/2$$

Isn't this a contradiction? The integers are closed under addition and subtraction, but we get a fraction. Why?

-
–  lab bhattacharjee Jun 23 at 16:04

The issue here is that addition of a finite number of terms is a nice, well-defined operation; addition of an infinite number of terms need not be.

In particular, rearranging terms in an infinite sum can actually change the sum. The series you have presented does not converge - and so discussing it as having a value is incorrect to begin with. However, there are series which converge, and which STILL cannot be rearranged without changing the value: this is true for series that are called conditionally convergent - that is, the series converges, but the sum of absolute values of the terms does not.

Interestingly, for conditionally convergent series, it turns out that you can rearrange the terms to give any limit that you like.

At the end of the day, the big thing to remember is this: addition of an infinite number of terms cannot be assumed to be associative or commutative, unless you know that the sum of the absolute values of the terms converges - a property known as absolute convergence.

-
Just because you can write a string of symbols that appear to respect normal mathematical syntax, such as $1-1+1-1+1-1+\cdots,$ it does not follow that the string is meaningful. Many mathematicians would indeed regard a string like this as meaningless, and not bother with it. Some, though, have played formal games with such strings to prove them "equal" to any number.