Dsa
Math
Easy
Greatest Common Divisor Count
Given two positive integers a and b, count how many integers in the range from 1 to a have a greatest common divisor with b that equals 1.
Input Format:
Two space-separated integers a and b (1 <= a, b <= 10^6).
Output Format:
A single line with the count of integers.
Example:
Input:
10 5
Output:
4
(1, 2, 3, 4 are coprime with 5)
Key concepts
mathgcdcount
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