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