Source: https://www.cemc.uwaterloo.ca/events/mathcircles/2013-14/Fall/Junior6_Oct8.pdf