Source: https://www.irif.fr/~asarin/P7/Algo/corrigexamalgo2010.pdf