Tuesday, May 7, 2019

How many sequences of consecutive integers are there where the sum equals the length




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?



Answer



The sum of $0 + 1 + 2 + \ldots + (n-1)$ is $\frac{n(n-1)}{2}$ (and has length $n$) so the sum of any length $n$ sequence of consecutive integers starting at $m$ is $nm + \frac{n(n-1)}{2}$ (since such sequences are of the form $m+0,m+1,m+2,\ldots,m+(n-1)$) and we need to solve the diophantine equation $$nm + \frac{n(n-1)}{2} = n.$$



We should cancel $n$ and double it to get $2m + n = 3.$ This equation will only have solutions for odd $n$, this tells us there are no even length sequences with that property. On the other hand if $n$ is odd, there is exactly one such sequence.






n | m  | 2m+n  | sequence
-------------------------
1 | 1 | 3 | 1

2 | impossible...
3 | 0 | 3 | 0 1 2
4 | impossible...
5 | -1 | 3 | -1 0 1 2 3
6 | impossible...
...

No comments:

Post a Comment

analysis - Injection, making bijection

I have injection $f \colon A \rightarrow B$ and I want to get bijection. Can I just resting codomain to $f(A)$? I know that every function i...