Copy code

def print_coprime_pairs(n):

for i in range(1, n+1):

for j in range(i+1, n+1):

if is_coprime(i, j):

print(f"({i}, {j})")

def is_coprime(a, b):

if a == 1 or b == 1:

return True

r = a % b

while r != 0:

a = b

b = r

r = a % b

return b == 1

To use this function, you can simply call print_coprime_pairs(n), where n is the upper bound of the range you want to consider. For example, calling print_coprime_pairs(10) would print out all pairs of co-prime numbers between 1 and 10, inclusive.