Source: https://panamaths.net/Documents/INFORMATIQUE/PilesFiles_TD_CORRIGE.pdf