Data Structures & AlgorithmsModerateICPC regional · TCS NQT

Problem: What is C(10, 3) modulo 7?

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

Correct answer: C. 1

C(10,3) = 10 · 9 · 8 / 6 = 120, and 120 = 7 · 17 + 1, so the remainder is 1. Reducing the numerator factors mod 7 first (3 · 2 · 1 = 6) and then dividing by 6 is a quicker route to the same 1; 0 would need 7 to divide 120, which it does not.

More Coding Interview Problems questions

Exams that ask this topic