solve problem 71 using farey sequence