Program Python do sprawdzenia numeru współ-prime
# Python program to check Co-Prime Number
# Function to check Co-prime
def are_coprime(a,b):
gcd = 1
for i in range(1, a+1): # We use a+1 because python will run for loop before a+1. That means the last number is a.
if a%i==0 and b%i==0:
gcd = i
return gcd == 1
# Reading two numbers
first = int(input('Enter first number: '))
second = int(input('Enter second number: '))
if are_coprime(first, second):
print(first,'&',second,'are co-prime')
else:
print(first,'&',second,'are NOT co-prime')
Troubled Trout