# I Have a (Not So) Little List

I am studying a six digit item number in a very long list of consecutively numbered items.

To my surprise I have found that if I add this item number to a certain number of the immediately lower item numbers, the result is the same as the sum of the same number of immediately higher item numbers.

Also, if I add the square of this item number to the squares of a different number of immediately lower item numbers, the result is the same as the sum of the squares of the same number of immediately higher item numbers.

What is the number that I am studying?

For the solution see here

This problem requires solving Pell’s equation $$y^2 = 2(2m+1)^2 – 1$$, where $$m$$ is the number of squares above $$x^2$$ and $$x = 2m(m+1)$$ is the desired number. I admit I used a computer for Pell’s equation.

As explained by Brian, the equation $$2x^2-y^2=pm1$$ can be solved easily by recursion, starting from $$(x_0, y_0) = (1,1)$$ and then using $$x_{i}=x_{i-1}+y_{i-1}, y_{i}=2x_{i-1}+y_{i-1}=x_{i-1}+x_{i}$$.
So one gets, almost by head, $(x, y)=(1,1),(2,3),(5,7),(12,17),(29,41), …$where both, $$x$$ and $$y$$ must be odd to obtain whole numbers of added item numbers.
Solving Pell’s equation $$x^2-Dy^2=1$$ to obtain the recursion coefficients is fairly well documented but solving $$x^2-Dy^2=N$$ for general values of $$N$$ to obtain the starting values is typically much harder. I hope to extend my coverage of this topic soon by describing the PQa algorithm, which forms the basis for finding these values in the general case. But, sadly, although I have a Python program for solving the general case, it is rather too complex to describe here.