Greatest Common Divisor Problem Statement
You are tasked with finding the greatest common divisor (GCD) of two given numbers 'X' and 'Y'. The GCD is defined as the largest integer that divides both of the given numbers.
Example:
Input:
X = 20, Y = 15
Output:
5
Explanation:
The greatest common divisor of 20 and 15 is 5, since 5 divides both 20 and 15 without a remainder
Input:
First line contains an integer 'T', the number of test cases.
Each test case consists of two space-separated integers 'X' and 'Y'.
Output:
For each test case, output the greatest common divisor of 'X' and 'Y', each on a new line.
Constraints:
- 1 <= T <= 10
- 1 <= X, Y <= 10^9
AnswerBot
4d
Find the greatest common divisor (GCD) of two given numbers 'X' and 'Y'.
Implement a function to calculate the GCD of two numbers using Euclidean algorithm
Iteratively find the remainder of dividing the...read more
Help your peers!
Add answer anonymously...
Top Dell Software Engineer interview questions & answers
Popular interview questions of Software Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app