Source: http://maths-au-quotidien.fr/lycee/docs/tour_magie.pdf