Data Structures & AlgorithmsHardGATE CS · TCS NQT

How many unordered pairs of distinct integers {a, b} from 1 to 12 are coprime to each other?

  1. A. 46
  2. B. 45
  3. C. 47
  4. D. 49

Correct answer: B. 45

Count all 66 pairs and subtract those sharing a prime factor, using inclusion-exclusion over the primes 2, 3, 5, 7, 11.

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

Exams that ask this topic