= Recognition criterion for triangular numbers
{title2=$M=T_n\quad\Longleftrightarrow\quad8M+1=(2n+1)^2$}
A <nonnegative integer> $M$ is a <triangular number> exactly when $8M+1$ is a <perfect square>. Its <square root> is then an <odd integer>, and the row index is
$$
n=\frac{\sqrt{8M+1}-1}{2}.
$$
Completing the square in $M=n(n+1)/2$ proves necessity; reversing the calculation proves sufficiency. For example, $8\cdot21+1=169=13^2$, giving $n=6$. In contrast, $8\cdot20+1=161$ lies strictly between $12^2$ and $13^2$, so twenty is not a <triangular number>. The criterion turns an apparently open-ended search through a <sequence> into one exact <perfect square> check.
Back to article page