$(a, b)$ pairs with $\gcd(a, b) = 1$

85 Views Asked by At

The title is stating clearly what I want to achieve, however, here's more background:
I'm trying to solve problem #71 in Project Euler and my question would be:
I'm not trying to count them as in this thread, I'm trying to get the actual (a, b) pairs instead! Is there a better (i.e. more efficient) approach than brute force?
Thanks.

1

There are 1 best solutions below

0
On

Since you don’t want us to solve the question for you, all that’s to be said has already been said in the comments. You can use Farey sequences; in particular, look at the section on Farey neighbours in the Wikipedia article, which should allow you to quickly find the left neighbour of $\frac37$.