Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python program to check Co-Prime Number

# 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')
Comment

PREVIOUS NEXT
Code Example
Python :: ordered dictionary python 
Python :: pyqt5 image 
Python :: train_size 
Python :: print index of tuple python 
Python :: python pandas replace not working 
Python :: factorial program 
Python :: how to check if a list is a subset of another list 
Python :: how to make calculator in python 
Python :: python is float 
Python :: how to combine two arrays in python 
Python :: how to distribute a dataset in train and test using scikit 
Python :: pytesseract.image_to_string save text file 
Python :: pandas slicing from one column to another 
Python :: python list comprehension elif 
Python :: convert url to base64 image py 
Python :: pytorch get gpu number 
Python :: python parse url get parameters 
Python :: python get first n elements of dict 
Python :: pandas select columns by index list 
Python :: python how to split a number 
Python :: example of django template for forms 
Python :: flask sqlalchemy query specific columns 
Python :: time.sleep() faster 
Python :: template string python 
Python :: panda3d 
Python :: pip install for python 2 and python3 
Python :: python set cwd to script directory 
Python :: is number python 
Python :: list tuples and dictionary in python 
Python :: dataframe from dict 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =