Source: https://w4.uqo.ca/dii/exercices/inf4003/SerieIV-STD-inf4003.pdf