Consecutive squares

FInd the sum of all positive integers n < 2017 n<2017 that have the property that n 2 + ( n + 1 ) 2 n^2 + (n+1)^2 is also a perfect square.


The answer is 838.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

6 solutions

Sharky Kesa
Oct 4, 2017

Note that these squares form a primitive Pythagorean Triplet, so there exist integers p p and q q such that n = p 2 q 2 n = p^2 - q^2 and n + 1 = 2 p q n+1 = 2pq (or the other way around). Thus, p 2 q 2 = 2 p q ± 1 ( p q ) 2 + 2 q 2 = ± 1 p^2 - q^2 = 2pq \pm 1 \implies (p-q)^2 + 2q^2 = \pm 1 .

Let u = p q u=p-q , and v = q v=q , so we have the Pell equations u 2 2 v 2 = 1 u^2 - 2v^2 = 1 and u 2 2 v 2 = 1 u^2 - 2v^2 = -1 .

Part 1: u 2 2 v 2 = 1 u^2 - 2v^2 = 1

The fundamental solution of this can be observed as being ( 3 , 2 ) (3, 2) . Thus, using the recursive formula ( u n + 1 , v n + 1 ) = ( u 0 u n + D v 0 v n , u 0 v n + v 0 u n ) (u_{n+1}, v_{n+1}) = (u_0 u_n + D v_0 v_n, u_0 v_n + v_0 u_n) , we get the following solutions: ( 3 , 2 ) , ( 17 , 12 ) , ( 99 , 70 ) , (3, 2), (17, 12), (99, 70), \ldots . These give the respective values for ( p , q ) (p,q) : ( 5 , 2 ) , ( 29 , 12 ) , ( 148 , 70 ) , (5, 2), (29, 12), (148, 70), \ldots , which respectively give these values for n n : n = 20 , 696 , 23660 , n=20, 696, 23660, \ldots . Thus, all satisfying n < 2017 n<2017 in this case are n = 20 , 696 n=20, 696 .

Part 2: u 2 2 v 2 = 1 u^2 - 2v^2 = -1

The fundamental solution for this can be observed as being ( 1 , 1 ) (1, 1) . Thus, using the recursive formula ( u n + 1 , v n + 1 ) = ( u 0 u n + D v 0 v n , u 0 v n + v 0 u n ) (u_{n+1}, v_{n+1}) = (u'_0 u_n + D v'_0 v_n, u'_0 v_n + v'_0 u_n) , where ( u 0 , v 0 ) (u'_0, v'_0) is the fundamental solution of u 2 2 v 2 = 1 u^2 - 2v^2 = 1 , we get the following solutions: ( 1 , 1 ) , ( 7 , 5 ) , ( 41 , 29 ) , (1, 1), (7, 5), (41, 29), \ldots . These give the respective values for ( p , q ) (p,q) : ( 2 , 1 ) , ( 12 , 5 ) , ( 70 , 29 ) , (2, 1), (12, 5), (70, 29), \ldots , which respectively give these values for n n : n = 3 , 119 , 4059 , n=3, 119, 4059, \ldots . Thus, all satisfying n < 2017 n<2017 in this case are n = 3 , 119 n=3, 119 .

Thus, we have all satisfying values of n n to be 3 , 20 , 119 , 696 3, 20, 119, 696 , so their sum is 838 \boxed{838} .


Note that another solution exists, using Vieta Root Jumping on ( p , q ) (p, q) .

Very nice. I used the fact that if ( x , y ) = ( a , b ) (x,y) = (a,b) is the smallest solution of x 2 2 y 2 = 1 x^2-2y^2=1 , then ( m , n ) (m,n) such that m + n 2 = ( a + b ) k m+n \sqrt{2} = \left(a+\sqrt{b}\right)^k , for some positive integer k k , produces all of the solutions to the equation. I didn't know there was a recursive way to find solutions! Alas, I've learned something new :) In hindsight, I realize that since there is a formula for finding all solutions to a Pell equation given that you know its fundamental solution, it makes sense for there to be a recursive approach.

Zach Abueg - 3 years, 8 months ago

Log in to reply

@Zach Abueg can you please write and explain your solution too

Vilakshan Gupta - 3 years, 8 months ago

got the solution via the pell equation but in a different way,

n 2 + ( n + 1 ) 2 = ( 2 x + 1 ) 2 n 2 + ( n + 1 ) 2 is odd 2 n 2 + 2 n + 1 = ( 2 x + 1 ) 2 1 2 × ( ( 2 n + 1 ) 2 + 1 ) = ( 2 x + 1 ) 2 ( 2 n + 1 ) 2 2 ( 2 x + 1 ) 2 = 1 \begin{aligned}n^2+(n+1)^2&=(2x+1)^2\hspace{4mm}\color{#3D99F6}\text n^2+(n+1)^2 \text { is odd}\\ 2n^2+2n+1&=(2x+1)^2\\ \dfrac{1}{2}\times((2n+1)^2+1)&=(2x+1)^2\\ (2n+1)^2-2(2x+1)^2&=-1\end{aligned}

setting u = ( 2 n + 1 ) u=(2n+1) and v = ( 2 x + 1 ) v=(2x+1) we get,

u 2 2 v 2 = 1 u^2-2v^2=-1

now we look for solutions where u u and v v are both odd and u < 4035 u<4035

Anirudh Sreekumar - 3 years, 8 months ago

@Sharky Kesa , I think you meant to write ( 99 , 70 ) (99,70) in Part 1. This would correspond to ( p , q ) = ( 169 , 70 ) (p,q)=(169,70) , and n = 23660 n=23660 , not 7252 7252 .

Miles Koumouris - 3 years, 8 months ago

Log in to reply

Thanks for spotting that!

Sharky Kesa - 3 years, 8 months ago
Mark Hennings
Oct 9, 2017

We want n 2 + ( n + 1 ) 2 = m 2 n^2 + (n+1)^2 = m^2 , so that ( 2 n + 1 ) 2 + 1 = 2 m 2 (2n+1)^2 + 1 = 2m^2 , and hence ( 2 n + 1 ) 2 2 m 2 = 1 (2n+1)^2 - 2m^2 \; = \; -1 The positive integer solutions of the equation x 2 2 y 2 = 1 x^2 - 2y^2 = -1 are well-known to be given by the formula x k + y k 2 = ( 1 + 2 ) 2 k + 1 k 0 x_k + y_k\sqrt{2} \; = \; (1 + \sqrt{2})^{2k+1} \hspace{2cm} k \ge 0 (the even powers of 1 + 2 1 + \sqrt{2} give the positive integer solutions of x 2 2 y 2 = 1 x^2 - 2y^2 = 1 ). The first 6 6 pairs ( x k , y k ) (x_k,y_k) are ( 1 , 1 ) (1,1) , ( 7 , 5 ) (7,5) , ( 41 , 29 ) (41,29) , ( 239 , 169 ) (239,169) , ( 1393 , 985 ) (1393,985) and ( 8119 , 5741 ) (8119,5741) , giving values of 0 , 3 , 20 , 119 , 696 , 4059 0,3,20,119,696,4059 for n n .

Larger values of k k yield larger values of n n . Thus the answer is 3 + 20 + 119 + 696 = 838 3 + 20 + 119 + 696 = \boxed{838}

Boi (보이)
Oct 4, 2017

This is considered as cheating.

Computational approach incoming, now with easy excel that doesn't even need any coding basics.


Write this in excel.

This is how it works.

Column B would be straightforward to understand, and so is column C;

Now floor it down by column D.

If the result of B is a square, then C is a natural number, then C=D. If the result of B wasn't, then C is not a natural number, then C>D.

Column E tries to calculate the square root of D-C, however, this will return an error: "#NUM!" if C>D.

Therefore, only two values can fill the column E, which are "0"s and "#NUM"s.

Get some filter on top of column E, and you're ready to go.


Now extend the list as 1 n 2017. 1\le n \le 2017.

(Click and drag the bottomright corner of A2 downwards till A2018. Select B2~E2, and click and drag the bottomright corner of E2 downwards till B2018~E2018.)


And then, click on the filter and deselect "#NUM".

It seems like the answer is 3 + 20 + 119 + 696 = 838 . 3+20+119+696=\boxed{838}.


Furthermore, typing this sequence up in Wolframalpha,

OEIS A001652 is the sequence where a n 2 + ( a n + 1 ) 2 {a_n}^2+(a_{n}+1)^2 is a square.

The terms are found by a recurrence formula which follows a n + 2 = 6 a n + 1 a n + 2 , a 0 = 0 , a 1 = 3. a_{n+2}=6a_{n+1}-a_{n}+2,~a_0=0,~a_1=3.

Again, this is cheating, considering this problem is a Number Theory problem.

Md Mehedi Hasan
Nov 19, 2017

I do it with C program.

First I keep the perfect squares in an array. Then I input n n 's value and check that for which n n ans matches with the perfect square which I kept in an array before. After that I added all n n for answer.

( n ) 2 + ( n + 1 ) 2 = ( n + x ) 2 (n)^2 +(n+1)^2 = (n+x)^2 So on expanding we get n 2 2 n ( x 1 ) ( x 2 1 ) = 0 n^2 -2n(x-1) - (x^2 -1) = 0 . So by quadratic equation formula we get n = 2 ( x 1 ) + ( 2 ( x 1 ) ) 2 + 4 ( x 2 1 ) 2 n = \frac{2(x-1) + \sqrt{(2(x-1))^2 +4(x^2 -1)}}{2} . For x x need to be an integer we need ( 2 ( x 1 ) ) 2 + 4 ( x 2 1 ) (2(x-1))^2 +4(x^2 -1) to be perfect square. So by expanding we get ( 2 ( x 1 ) ) 2 + 4 ( x 2 1 ) = 8 x ( x 1 ) (2(x-1))^2 +4(x^2 -1) = 8x(x-1) . we can check for perfect square in 2 x ( x 1 ) 2x(x-1) . x x and 2 ( x 1 ) 2(x-1) needs to be perfect squares or 2 x 2x and ( x 1 ) (x-1) needs to be perfect squares. We can check each of the squares doubles. Thus we get 2,8,18,32,50,72,98,128,162,200,242,288,338,392,450,512,578,648,722,800,882,968,1058 etc for first few squares. we get some squares from its +1 or -1 then we get a value. 2-1=1,8+1=9,50-1=49, 288+1=289 are the squares we get from these. substituting these values in the quadratic equation we get n n as 3 , 20 , 119 , 696 3,20,119,696 . Thus the final answer is 696 + 119 + 20 + 3 = 838 696+119+20+3=838

We use Latex, not Tex. Just replace $$...$$ with \ ...\ and $...$ with \ ...\ .

Sharky Kesa - 3 years, 7 months ago
James Wilson
Nov 2, 2017

My solution wasn't as good as the others. I just used the PPT formulas to set up the two quadratic equations. The discriminant of each of those equations was 2 p 2 + 1 2p^2+1 . So I checked all the values of p p from 1 to 40 (by hand too) to see which produced a perfect square. There were only two: 2 2 and 12 12 . There turned out to be two values of n n corresponding to each for a total of four values: 3 , 20 , 120 , 696 3,20,120,696 .

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...