Source: https://www.math.u-bordeaux.fr/~ajehanne/Licence/AlgoMath/MoindresCarres.pdf