Source: https://www.math.u-bordeaux.fr/~mibonnef/cpp-proba/correction-DS-CPP_proba-2013.pdf