Source: http://maths-olympiques.fr/wp-content/uploads/2017/10/ofm-2013-2014-envoi-4-solutions.pdf