This is an example of applying Lagrange's four-square theorem, which states that every positive integer can be written as the sum of at most four squares. The first published proof was given by Lagrange (1736–1813) in 1770.

Reference

[1] G. N. Frederickson, Dissections: Plane & Fancy, New York: Cambridge University Press, 2002 p. 96.