Source: https://mathematiques.ac.free.fr/IMG/pdf/Algorithmique_Casio_2de.pdf