Source: https://mathschallenge.net/problems/pdfs/mathschallenge_1_star.pdf