ProgrammingVery hardTCS NQT · Accenture

Compute C(10, 3) modulo 7 using Pascal's rule C(n, k) = C(n-1, k-1) + C(n-1, k), reducing every entry mod 7. What is printed?

Compute C(10, 3) modulo 7 using Pascal's rule C(n, k) = C(n-1, k-1) + C(n-1, k), reducing every entry mod 7. What is printed?
build the table C[n][k] for 0 <= k <= n <= 10 with C[n][0] = C[n][n] = 1
C[n][k] = (C[n-1][k-1] + C[n-1][k]) mod 7
Print C[10][3]
  1. A. 120
  2. B. 1
  3. C. 0
  4. D. 3

Correct answer: B. 1

C(10,3) = 120 and 120 mod 7 = 1. Forgetting the reduction gives 120, reading the wrong column C(10,4) gives 210 mod 7 = 0, and C(10,2) = 45 gives 3.

More Pseudocode and Code Tracing questions

Exams that ask this topic