Source: https://math-adore.fr/cours/terminalestmg/suitearithmetiquealgorithme.pdf