Co-prime Checker

4.4

9 votes
Problem

Assume your brother studies in class 2. He has to complete his homework on co-primes. As an elder sibling help him in finding whether the given two numbers are co-prime or not.

Input Description:

You will be given two numbers ‘n’ and ‘m’

Output Description:

Your task is to tell whether numbers are coprime or not. If it is a co-prime print 1 else 0

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

The concept of co-prime numbers is that two numbers are co-prime if their greatest common divisor (GCD) is 1. In other words, if two numbers do not have any common factors other than 1, they are coprime. For example, the numbers 3 and 5 are coprime because their only common factor is 1.

In this problem, you are given two numbers n and m. You need to determine whether they are coprime or not. If the numbers are coprime, you should output 1, otherwise, we should output 0.

Editor Image

?