Jonathan. Frech’s WebBlog

Triangular Squares (#133)

Jonathan Frech

In a recent video, Matt Parker showed a triangular num­ber that also is a square num­ber, 6, and asked if there were more.

A triangular num­ber has the form $\frac{n^2+n}{2}$$\frac{n^2+n}{2}$ — shown by Euler — and a square num­ber has the form $m^2$$m^2$.
Triangular squares are those numbers for which $\frac{n^2+n}{2}=m^2$$\frac{n^2+n}{2}=m^2$ with $n,m\in\mathbb{N}$$n,m\in\mathbb{N}$.
Examples are $\{0,1,6,35,204,1189,6930,\dots\}$$\{0,1,6,35,204,1189,6930,\dots\}$ (sequence A001109 in OEIS).

To check if triangular numbers are square numbers is easy (code listed below), but a mathematical function would be nicer.
The first thing I tried was to define the triangular num­ber’s square root as a whole num­ber, $\sqrt{\frac{n^2+n}{2}}=\lfloor\sqrt{\frac{n^2+n}{2}}\rfloor$$\sqrt{\frac{n^2+n}{2}}=\lfloor\sqrt{\frac{n^2+n}{2}}\rfloor$. This function does not return the square numbers that are triangular but the triangular numbers that are square.
The resulting sequence is $\{0,1,8,49,288,1681,9800,\dots\}$$\{0,1,8,49,288,1681,9800,\dots\}$ (sequence A001108 in OEIS).

Source code: triangular-squares.py