Data Structures & AlgorithmsModerateGATE CS · ICPC regional
How many integers x with 1 <= x <= 200 satisfy gcd(x, 180) = 1?
- A. 55
- B. 50
- C. 59
- 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.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- What is the smallest x such that lcm(1, 2, ..., x) exceeds 1,000,000?
- How many integers x with 1 <= x <= 100 satisfy x^2 mod 24 = 1?
- How many ordered pairs (i, j) with 1 <= i, j <= 18 have i j divisible by 18?
- How many contiguous subarrays of [2, 8, 3, 3, 2, 6] have a product that is a perfect square?
- How many contiguous subarrays of [1, 3, 2, 6, 4, 2] have a sum divisible by their length?
- Evaluate the integer expression 2 - 3 4 + 10 / 3 using standard precedence and integer division that truncates toward zero. What is the…