Data Structures & AlgorithmsModerateGATE CS · ICPC regional
How many integers in [1, 200] are coprime to 210?
- A. 47
- B. 48
- C. 49
- D. 51
Correct answer: A. 47
210 = 2 * 3 * 5 * 7, so a number is coprime to 210 when it avoids all four primes; inclusion-exclusion over the four primes gives the count.
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 sum of all integers in [1, 50] that are either perfect squares or perfect cubes?
- What is the greatest common divisor of 6, 24, 60, 120 and 210?
- How many trailing zeros does 50! have when written in base 12 (note 12 = 2^2 3)?
- How many integers x in [1, 1000] satisfy x ≡ 2 (mod 13) and x ≡ 5 (mod 17)?
- How many index pairs i < j in [1, 2, ..., 10] (the integers 1 to 10) have i j divisible by 4?
- Start with the stack [1]. Operations in order: DUP (push a copy of the top), ADD (pop two and push their sum), DUP, DUP, ADD, ADD. What is…