This question comes from trying to see why 24 is the only non-trivial value of $n$ for which
$$1^2+2^2+3^2+\cdots+n^2$$
is a perfect square.
To this end, let $m,n \in \mathbb N$ be such that $1^2+2^2+3^2+\cdots+n^2 = m^2$, or
$$n(n+1)(2n+1) = 6m^2.$$
When $n=24$ the left hand side is $24\times 25 \times 49$ and there are two things that make it work as a solution:
$$7^2+1=2\times5^2$$
$$7^2-1=12\times2^2.$$
We can write these algebraically as
$$x^2=2y^2-1$$
$$x^2=12z^2+1$$
and solve them simultaneously (with $x,y,z\in \mathbb N$).
These are instances of Pell's equation and each individually has an infinite number of solutions.
How do we show there is only one (non-trivial) value of $x$ that is common to the solutions of both equations?
This problem is sometimes called cannonball problem or square pyramid problem.
Maybe you may have a look at MathWorld or Wikipedia and some references therein.
Elementary solution is given in W. S. Anglin: The Square Pyramid Puzzle, The American Mathematical Monthly, Vol. 97, No. 2 (Feb., 1990), pp. 120-124.
Further useful references:
Henri Cohen: Number Theory: Tools and diophantine equations, Section 6.8.2
S. C. Althoen and C. B. Lacampagne: Tetrahedral Numbers as Sums of Square Numbers, Mathematics Magazine, Vol. 64, No. 2 (Apr., 1991), pp. 104-108
Online resources: