Data Structures & AlgorithmsModerateICPC regional · TCS NQT

Problem: Find the modular inverse of 7 modulo 26 (the value x with 0 ≤ x < 26 such that 7x ≡ 1 mod 26).

  1. A. 11
  2. B. 15
  3. C. 1
  4. D. 19

Correct answer: B. 15

Extended Euclid gives 1 = 3·26 − 11·7, so x ≡ −11 ≡ 15 (check: 7 · 15 = 105 = 4·26 + 1). Dropping the minus sign gives 11 (7 · 11 ≡ −1), applying Fermat's 7^(26−2) to the non-prime 26 gives 1, and 26 − 7 = 19 is the additive inverse.

More Coding Interview Problems questions

Exams that ask this topic