Data Structures & AlgorithmsModerateCodeforces Div2 B · modular arithmetic

Problem: What is 3^100 mod 10?

  1. A. 9
  2. B. 3
  3. C. 7
  4. D. 1

Correct answer: D. 1

The last digit of powers of 3 cycles 3, 9, 7, 1 with period 4. Since 100 is divisible by 4, the result is 1.

More Coding Interview Problems questions

Exams that ask this topic