Data Structures & AlgorithmsModerateCodeforces Div2 B · CRT

Problem: What is the smallest positive integer x with x ≡ 1 (mod 4) and x ≡ 2 (mod 5)? Run the code.

Problem: What is the smallest positive integer x with x ≡ 1 (mod 4) and x ≡ 2 (mod 5)? Run the code.
print(next(x for x in range(1, 100) if x % 4 == 1 and x % 5 == 2))
What is printed?
  1. A. 6
  2. B. 17
  3. C. 12
  4. D. 22

Correct answer: B. 17

17 = 4 * 4 + 1 and 17 = 5 * 3 + 2, and 17 is the smallest such number.

More Coding Interview Problems questions

Exams that ask this topic