# 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
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.3872045874595642, "perplexity": 4896.171114939652}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2014-35/segments/1408500835872.63/warc/CC-MAIN-20140820021355-00005-ip-10-180-136-8.ec2.internal.warc.gz"}