# A number that is a triangle number and also a square number.

This is a problem from standupmaths, from Youtube.

Question:

Think of a number which is a triangle number and a square number.

This can be expressed using a single equation:

$$x^2=\frac{y(y+1)}{2}$$

If you use trial and improvement, you have the square numbers:

$[1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289...]$

And triangle numbers:

$[1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210...]$

The only numbers that appears in both of these lists are $$36, 6^2 = 36, \frac{8*9}{2} = 36, 1, 1^2=1, \frac{1*2}{2}=1$$

Are there any beyond this?

Well, $2x^2=y^2+y$. How do I go on from this? What do I have to use?

What are the numbers where the number you substitute in are equal, and their results are equal?

Lets say:

What if $x=y$?

$$x^2=\frac{x(x+1)}{2}$$

$2x^2=x(x+1)$

$2x^2=x^2+x$

$x^2-x=0$

$x(x-1)=0$

$x$ or $(x-1)$ has to be $0$.

Therefore, $x = 0.5\pm 0.5$

Second question:

But is $0$ technically a square or triangle number?

From your equation you get $$8x^2=4y^2+4y$$ or $$8x^2+1=(2y+1)^2.$$ You need to solve $$z^2-8x^2=1$$ in positive integers ($z$ will automatically be odd so $y=\frac12(z-1)$ will be an integer). This is a form of Pell's equation. Its solutions are $(x_n,z_n)$ where $$z_n+2\sqrt 2 x_n=(3+2\sqrt 2)^n.$$ So $x_1=1$, $z_1=3$ giving $1$ as square-triangular. Then $x_2=6$, $z_2=17$ giving $36$ as square-triangular. Then $x_3=35$, $z_3=99$ giving $1225$ as square-triangular, etc.

• edited $z^2 - 8 z^2 = 1$ to $z^2 - 8 x^2 = 1.$ Also posted my own answer, I recently learned a by-hand method for Pell that I really like, from Prof. Jonathan Lubin (link in answer) – Will Jagy May 6 '17 at 16:37

Following Shark, here is how to solve the Pell equation $z^2 - 8 x^2 = 1$ by hand, although one can easily guess the first as $9-8=1:$

Method described by Prof. Lubin at Continued fraction of $\sqrt{67} - 4$

$$\sqrt { 8} = 2 + \frac{ \sqrt {8} - 2 }{ 1 }$$ $$\frac{ 1 }{ \sqrt {8} - 2 } = \frac{ \sqrt {8} + 2 }{4 } = 1 + \frac{ \sqrt {8} - 2 }{4 }$$ $$\frac{ 4 }{ \sqrt {8} - 2 } = \frac{ \sqrt {8} + 2 }{1 } = 4 + \frac{ \sqrt {8} - 2 }{1 }$$

Simple continued fraction tableau:
$$\begin{array}{cccccccccc} & & 2 & & 1 & & 4 & \\ \\ \frac{ 0 }{ 1 } & \frac{ 1 }{ 0 } & & \frac{ 2 }{ 1 } & & \frac{ 3 }{ 1 } \\ \\ & 1 & & -4 & & 1 \end{array}$$

$$\begin{array}{cccc} \frac{ 1 }{ 0 } & 1^2 - 8 \cdot 0^2 = 1 & \mbox{digit} & 2 \\ \frac{ 2 }{ 1 } & 2^2 - 8 \cdot 1^2 = -4 & \mbox{digit} & 1 \\ \frac{ 3 }{ 1 } & 3^2 - 8 \cdot 1^2 = 1 & \mbox{digit} & 4 \\ \end{array}$$

Anyway, given a solution $(z,x)$ in positive integers to $z^2 - 8 x^2 = 1,$ we get the next in an infinite sequence by $$(z,x) \mapsto (3z + 8x, z + 3x),$$ so $$( 1,0 ),$$ $$(3,1),$$ $$( 17,6),$$ $$(99 ,35 ),$$ $$( 577, 204 ),$$ $$(3363 , 1189 ),$$ By Cayley -Hamilton, the coordinates $z_n, x_n$ obey $$z_{n+2} = 6 z_{n+1} - z_n,$$ $$x_{n+2} = 6 x_{n+1} - x_n.$$