Data Structures & AlgorithmsHard

How many subsequences of EXACTLY three elements of 6 10 15 4 9 (position subsets) have gcd equal to 1?

  1. A. 3
  2. B. 2
  3. C. 0
  4. D. 8

Correct answer: D. 8

The gcd of a triple is the gcd of the first two combined with the third; enumerate triples and test. Counting pairs, the complement, or testing only one element against the others each give other counts.

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

Exams that ask this topic