Question bank › Math
Dsa Math Medium

Greatest Common Divisor (GCD)

Implement a program to calculate the Greatest Common Divisor (GCD) of two positive integers using the Euclidean algorithm. Print the GCD. ### Input Format: Two positive integers a and b (1 <= a, b <= 10^6). ### Output Format: A single integer representing the GCD of a and b. ### Example: Input: 48 18 Output: 6 ### Explanation: The greatest divisor common to both 48 and 18 is 6.

Key concepts

mathgcdeuclidean algorithm

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.