"The first two numbers that are both squares and triangles are 1 and 36. Find the next one and, if possible, the one after that. Can you figure out an efficient way to find triangular–square numbers? Do you think that there are infinitely many?"
Thanks.
$${t_n} = \sum\limits_{k = 1}^n k = 1 + 2 + 3 + \cdots + n = \frac{{n\left( {n + 1} \right)}}{2} = n-th{\text{ triangular number}}$$ $${s_m} = {\text{m-th square number}} = {m^2}$$ $${s_m} = {t_n} \Rightarrow \frac{1}{2}n\left( {n + 1} \right) = {m^2}$$ $$\frac{1}{2}{\left( {n + \frac{1}{2}} \right)^2} = \frac{1}{2}\left( {{n^2} + n + \frac{1}{4}} \right) = \frac{1}{2}\left( {{n^2} + n} \right) + \frac{1}{8}$$ $$\frac{1}{2}n\left( {n + 1} \right) = \frac{1}{2}\left( {{n^2} + n} \right) = \frac{1}{2}{\left( {n + \frac{1}{2}} \right)^2} - \frac{1}{8} = {m^2}$$ $$\frac{1}{2}{\left( {n + \frac{1}{2}} \right)^2} - {m^2} = \frac{1}{8}$$ $$4{\left( {n + \frac{1}{2}} \right)^2} - 8{m^2} = 1$$ $$2 \cdot \left( {n + \frac{1}{2}} \right) \cdot 2\left( {n + \frac{1}{2}} \right) - 8{m^2} = 1$$ $${\left( {2n + 1} \right)^2} - 8{m^2} = 1$$ $${\left( {2n + 1} \right)^2} - 2 \cdot {\left( {2m} \right)^2} = 1$$ $$\boxed{w \equiv 2n + 1}$$ $$\boxed{z \equiv 2m}$$ $$\boxed{{w^2} - 2{z^2} = 1}$$
Finding numbers that satisfy the last equation above isn't all that simple... so I found the first numbers that are both triangular and square using python
Code output
$$\begin{array}{*{20}{c}} & {{\rm{Square (}}{m^2}){\rm{ and Triangular}}}&& m&& n& \\ \hline & 1&& 1&& 1& \\ & {36}&& 6&& 8& \\ & {1225}&& {35}&& {49}& \\ & {41616}&& {204}&& {288}& \\ & {1413721}&& {1189}&& {1681}& \\ & {48024900}&& {6930}&& {9800}& \end{array}$$