Source: http://maths-olympiques.fr/wp-content/uploads/2017/10/ofm-2016-2017-envoi-3-solutions.pdf