# Problem on Consecutive Sequence Sums that are Squares

Here is a seemingly simple Problem:

I have two natural numbers n and m, n < m such that S1:= n +...+ m is a square and also S2:= n +...+ m + (m+1) is a square.

Problem a) : Find n and m. You find a solution by looking at my demonstration "Sequence Sums that are Squares".

Problem b) : Now here is the hard part: find a second solution (maybe with a Mathematica program?) or prove that no other solution exists.

-
Care to share the code you are working on ? –  Sektor Jan 14 at 20:19
n=837, m=844 (found with considerable assistance from Mathematica) –  Daniel Lichtblau Jan 14 at 21:36
@DanielLichtblau IntegerQ@Sqrt@Sum[i, {i, 21, #}] & /@ {28, 29} –  belisarius Jan 14 at 21:49
FindInstance[ Sum[i, {i, n, m}] == a a && Sum[i, {i, n, m + 1}] == b b && n < m && And @@ Thread[{a, b, m, n} > 0], {a, b, m, n}, Integers] –  belisarius Jan 14 at 21:51

(Getting a bit lengthy for a comment.)

Here are several {m,n} pairs that work.

{{28, 21}, {168, 120}, {984, 697}, {5740, 4060}, {115, 109}, {3475, 3252}, {620, 604}, {1999, 1969}, {844, 837}, {28704, 28417}, {10259, 10189}, {19060, 18964}, {32575, 32449}, {52244, 52084}, {79699, 79501}, {28564, 28557}, {166488, 166440}, {100803, 100797}, {970228, 970221}}

There is perhaps a probabilistic argument to be made for their density in NxN.

Those pairs come from the Solve below giving a certain radical, and then testing for values that make the radical integral.

ss = Solve[{m*(m + 1) - n*(n - 1) - 2*t^2 == 0, 2*t*j + j^2 - (m + 1) == 0, m >= n + 1, n >= 1, j >= 1, t >= 1}, {m, n, t, j}, Integers]

-

There are closed form expressions for the two sums. Set the first sum to $g^2=(m-n+1)(m+n)/2$, the second to $h^2=(m-n+2)(m+n+1)/2$. UseReduceto find an expression for $n$.

Reduce[{(m-n+1)(m+n)==2 g^2, (m-n+2)(m+n+1)/2==g^2+m+1, g>0, m>0, 0<n<m},
{g,m,n}, Integers]


TheReduceoutput is divided into three parts, but essentially requires integer $n=(u+1)/2$, where $u^2=4m(m+1)+1-8g^2$. Assume $m$ is given. Solve $u^2+8g^2=4m(m+1)+1$, and select those pairs $\{u,g\}$ having $n=(u+1)/2 \ne m$ and integer $h=\sqrt{g^2+m+1}$. A Cornacchia algorithm is much faster thanReduce, but useReducehere as in

Block[{r},
Flatten[Table[
r={ToRules[Reduce[{4m(m+1)+1==u^2+8g^2, u>0, g>0}, {u,g}, Integers]]};
If[r =!= {},
Select[{u,g} /.r, #[[1]]!=2m-1 && IntegerQ[Sqrt[#[[2]]^2+m+1]]&],
{}] /. {u_Integer,g_Integer} -> {m, (u+1)/2, g, Sqrt[g^2+m+1]},
{m, 2, 2000}],1]]


Not exactly @DanielLichtblau's one-liner, but it works...

-
I used something more like a 15-liner to do the actual work. It wasn't all that well coded, and nor was it terribly enlightening, so I didn't add it to my post. –  Daniel Lichtblau Jan 15 at 16:42