Data Structures & AlgorithmsHardGATE CS · TCS NQT

What is the sum of gcd(a, b) over all unordered pairs of distinct elements of [6, 10, 15]?

  1. A. 11
  2. B. 10
  3. C. 30
  4. D. 8

Correct answer: B. 10

The three pairs have gcd 2, 3 and 5, which total 10. Taking the product of each pair instead of the gcd is the usual slip.

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

Exams that ask this topic