Source

I got a variant of this problem from Rustan Leino, who came up with it after being inspired by a problem from Madan Musuvathi.

I solved it and wrote up my solution.

Problem

There's a simple technique that, given any integer $N > 2$, allows you to figure out the other two integer sides of a right triangle in your head (or with pen and paper if the numbers get too large). Find this technique.

Hints

- Start with the case that $N$ is odd.
- Move one of the addends of the Pythagorean Theorem to the other side and factor it (a technique Rustan learned from Raymond Boute).

Solution
Reveal

If $N$ is odd, use $(N^2-1)/2$ and $(N^2+1)/2$. If $N$ is even, use $N^2/4-1$ and $N^2/4+1$.