# Square-Trangular Numbers Checking Answer

Problem: The first 2 numbers that are both squares and triangles are 1 and 36. Find the next one and if possible, the one after that.

Problem: Can you figure out an efficient way to find triangular-square numbers?

Answer: $s^2 = t(t+1)/2$, where $s,t \epsilon{} \textbf{Z}$.

Problem: Do you think that there are infinitely many?

Answer: Yes. (Can someone give me an justification for my answer?)

• $s^2 = t(t + 1)/2$ is a statement of the problem, not a solution to it. How do you propose to solve this equation? – Qiaochu Yuan May 17 '13 at 19:58

Your answer is correct: the third and fourth both-triangular-and-square numbers are 1225 and 41616. There are infinitely many such numbers, all of them being solutions to the equation $s^2 = \frac{1}{2}t(t+1)$ in integers. What you didn't provide is an efficient method for finding further solutions to this equation.

The equation can be rewritten as $(2t+1)^2 - 8s^2 = 1$, which is just a slightly disguised Pell's equation. There are a few general methods for solving such equations. Applying one of them to your case yields a simple recurrence for values of $s$: $s_0=0$, $s_1=1$, $s_{k+2} = 6s_{k+1} - s_k$.

Hint: rearrange your equation as a quadratic in $t$. You will find you need $\sqrt {1+8s^2}$ to be a perfect square to make $t$ an integer. Then look up Pell's equation.

The condition for finding such numbers is to use the square-root-of-two approximation.

   0    1    2    5   12   29   70   169      A   A' = A+B
1    1    3    7   17   41   99   239      B   B' = A+A'


The square roots of the numbers you require to be both square and triangular, are then the product of the two numbers in the same column, ie $AB$.

So, for example, $70*99 = 6930$, $6930*6930 = 48024900$, while $(9800 * 9801)/2$ gives the same result. So the triangular number of 9800 and the square of 6930 gives the same answer.

One sees that in the values of 9800 and 9801, that $9800=2*70^2$ and $9801=99^2$. The ratio of $99/70$ is an approximation to $\sqrt{2}$, which the iterative process above does.

The ratio between the numbers in this table settles down to $\sqrt{2}+1$, which is the so-called silver ratio.

It produces them all, and no others.