Source: https://cedric.cnam.fr/~lamberta/enseignements/C/corrections/07/correction_tp7.pdf