Data Structures & AlgorithmsModerateICPC regional · TCS NQT

Problem: Compute 7^2024 modulo 9.

  1. A. 5
  2. B. 4
  3. C. 3
  4. D. 6

Correct answer: B. 4

Powers of 7 modulo 9 cycle with period 3: 7, 4, 1. Since 2024 is a multiple of 3 plus 2, the residue is the second term of the cycle, which is 4.

More Coding Interview Problems questions

Exams that ask this topic