Data Structures & AlgorithmsVery hardICPC regional · number theory

Problem: Compute C(10, 3) mod 7 using Lucas' theorem, where 7 is prime. What is the result?

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

Correct answer: C. 1

In base 7, 10 = (1,3) and 3 = (0,3), so Lucas gives C(1,0) * C(3,3) = 1. Taking 120 mod 7 gives the same answer, while reading the digits without carry gives the trap.

More Coding Interview Problems questions

Exams that ask this topic