Data Structures & AlgorithmsVery hardGATE CS · ICPC regional

How many integers x in [0, 20] satisfy x^3 ≡ x (mod 7)?

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

Correct answer: B. 9

Fermat's little theorem gives x^7 ≡ x, so x^3 ≡ x holds on the residues that are 0 or x^2 ≡ 1 mod 7, i.e. 0, 1 and 6 modulo 7.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic