Data Structures & AlgorithmsModerateICPC regional · GATE CS

Problem: The Euler's criterion test: count the quadratic residues modulo 13 among 1 through 12 (a residue r satisfies x² ≡ r for some integer x).

  1. A. 7
  2. B. 6
  3. C. 12
  4. D. 3

Correct answer: B. 6

Squares mod 13 of x = 1..12 repeat in pairs (x and 13 − x), giving (13 − 1)/2 = 6 distinct residues {1, 3, 4, 9, 10, 12}. Adding 0 gives 7, not removing duplicates gives 12, and 3 counts only perfect squares 1, 4, 9 without reducing mod 13.

More Coding Interview Problems questions

Exams that ask this topic