Source: http://math.univ-lyon1.fr/irem/Formation_ISN/formation_rs232/tp/ISN_TP_rs232_eleve_correction.pdf