Source: http://profmath.uqam.ca/~fabiennevenant/MAT3812/hiver13/MAT3812--13/algo.pdf