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
4mo
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...
Dell Software Engineer interview questions & answers
A Software Engineer was asked 8mo agoQ. What is polymorphism?
A Software Engineer was asked 8mo agoQ. What is the difference between abstraction and Interface?
A Software Engineer was asked 8mo agoQ. How is abstraction implemented?
Popular interview questions of Software Engineer
A Software Engineer was asked 8mo agoQ1. How is abstraction implemented?
A Software Engineer was asked 8mo agoQ2. What is polymorphism?
A Software Engineer was asked 11mo agoQ3. Given an array of integers, find the second largest element.
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

