# Any Ideas On This Simple Co-Prime program

#### Gogi

So the program that I want to make it is about printing all the pair co-prime numbers in a given range, if type 10 it has to print out every co-prime number like {1,2} , {2,3} and so on until it reaches the the typed number. So I have to make it with a range that i give and it has to print out every possible pair of co-prime numbers in it. Maybe it has to have an outside of the main function and then it should be called in the main. I don't know can you guy help me.

Any ideas ?

#### tomval4

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.