### Generate tuples of pairwise coprimes with limit on largest element

Posted:

**Sun Jun 30, 2019 4:42 pm**I'm trying to find an efficient way to find tuples or arrays with 10 elements of pairwise coprime integers below a given limit M. How would I write the following program?

loop over all (a,b,c,d,e,f,g,h,i,j) such that 0 < a < b < c <d < e < f < g < h < i <j <M and gcd(a,b,c,d,e,f,g,h,i,j) == 1

.. do something

end loop

I already have a function compute gcd and my code works using nested for loops for small values of M need code for values as large as M = 10^6

loop over all (a,b,c,d,e,f,g,h,i,j) such that 0 < a < b < c <d < e < f < g < h < i <j <M and gcd(a,b,c,d,e,f,g,h,i,j) == 1

.. do something

end loop

I already have a function compute gcd and my code works using nested for loops for small values of M need code for values as large as M = 10^6