Data Structures & AlgorithmsModerateGATE CS · ICPC regional

How many integers x with 1 <= x <= 200 satisfy gcd(x, 180) = 1?

  1. A. 55
  2. B. 50
  3. C. 59
  4. D. 54

Correct answer: D. 54

Since 180 = 2^2 * 3^2 * 5, x is coprime exactly when it is divisible by none of 2, 3 or 5. Inclusion-exclusion over these primes gives the count per 180 numbers.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic