TITLE: How many sequences of consecutive integers are there where the sum equals the length
QUESTION [8 upvotes]: I am really sad and I noticed that the sequence:
$0 , 1 , 2$
Has its sum equal to its length.
I was wondering how many these existed.
e.g:
$ 1$
$-3 , -2 , -1 , 0 , 1 , 2 , 3 , 4 , 5$  $(= 9)$
I got so far and got stuck, I reduced it down to finding out how many solutions there are to the equation:
$m^2 - n^2 + m + n = 0$   ,  $0 < n < m$ 
Can anyone tell me how to find this out?

REPLY [5 votes]: The sum of a nonempty sequence of numbers is equal to its length if and only if the average of its terms is $1$. The average of a sequence of consecutive integers is an integer if and only if the length of the sequence is odd, in which case it is the middle term of the sequence. So you are looking at the set of all odd-length sequences of successive integers whose middle term is $1$; these are easy to list, and there are infinitely many of them. Don't forget the empty sequence, which also qualifies.