Source: http://www.panamaths.net/Documents/INFORMATIQUE/PilesFiles_TD_CORRIGE.pdf