Source: https://web.math.princeton.edu/mathlab/jr02fall/Periodicity/mariusjp.pdf