![]() |
VOOZH | about |
Two numbers A and B are said to be Co-Prime or mutually prime if the Greatest Common Divisor of them is 1. You have been given two numbers A and B, find if they are Co-prime or not.
Examples :
Input : 2 3
Output : Co-Prime
Input : 4 8
Output : Not Co-Prime
The idea is simple, we find GCD of two numbers and if GCD is 1, we return true, else false.
Co-Prime Not Co-Prime
Time Complexity: O(log(max(a,b)))
Auxiliary Space: O(1)