Source: https://www.lri.fr/~jcohen/documents/enseignement/td-RIP-correction.pdf