Source: https://gauss.math.luc.edu/greicius/Math201/Fall2012/Lectures/linear-congruences.article.pdf