Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

How many pairs i < j in [2, 3, 4, 6, 9] have gcd(a[i], a[j]) = 1?

  1. A. 5
  2. B. 3
  3. C. 6
  4. D. 4

Correct answer: D. 4

Check each of the 10 pairs with gcd. The coprime pairs are (2,3), (2,9), (3,4) and (4,9), so the count is 4.

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

Exams that ask this topic