Source: http://maths.spip.ac-rouen.fr/IMG/pdf/Algo_LARP_-_corriges.pdf