Solve #9 with math!