How to find all possible values of four variables when squared sum to N?

Viewed 7760

A^2+B^2+C^2+D^2 = N Given an integer N, print out all possible combinations of integer values of ABCD which solve the equation.

I am guessing we can do better than brute force.

4 Answers
Related