Sum of Natural Number Ranges? Given a positive integer $n$, some positive integers $x$ can be represented as follows:
$$1 \le i \le j \le n$$
$$x = \sum_{k=i}^{j}k$$
Given $n$ and $x$ determine if it can be represented as the above sum (if $\exists{i,j}$), and if so determine the $i$ and $j$ such that the sum has the smallest number of terms. (minimize $j-i$)
I am not sure how to approach this.  Clearly closing the sum gives:
$$x = {j^2 + j - i^2 + i \over 2}$$
But I'm not sure how to check if there are integer solutions, and if there are to find the one with smallest $j-i$.

A start: Note that
$$2x=j^2+j-i^2+i=(j+i)(j-i+1).$$
The two numbers $j+i$ and $j-i$ have the same parity (both are even or both are odd). So we must express $2x$ as a product of two numbers of different parities. 
