Source: https://www.irif.fr/~francoisl//DIVERS/l3algo-td4cor-0809.pdf