A number is triangular if it satisfies the formula for some positive integer . The square-triangular numbers are numbers that are both triangular and the square of a positive integer.

Letting the n-th triangular number equal

…and the square of the m-th positive integer equal … it follows that a positive integer is both triangular and a square if

for some value of n and some value of m. Finding pairs of values of m and n that satisfy this equation is not easy by hand. The following manipulations of the equations above allow for the use of a simple python algorithm to find square-triangular numbers.

The following two definitions will help simplify the equation above:

With the definitions of w and z above, can be re-written as

Finding values of w and z that satisfy the equation above is not simple, but solutions can be found easily in Python. The following short algorithm finds the first 6 square-triangular numbers.