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
Be the first one to answer
Add answer anonymously...
Dell Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter