Solution

ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2013/discrete-mathematics-probability-and-continuous-mathematics/2/f/solution

Use modular arithmetic to keep all intermediate numbers small:
Thus . Cubing gives

New to topics? Read the docs here!