Source: https://www.kiteb.net/education/informatique/bac/bacinfo2017/bac-pratique-27052017-algo-corrige1.pdf