You can use the formula <strong>(n*(n+1))/2=N</strong> and convert them into a quadratic equation to solve the problem. You can check my solution for this problem [link text][1]
Here i use sheree dharacharya formula to find the solution. ~~
~~And it accepted in one go.
[1]: https://www.codechef.com/viewsolution/17601462