Data Structures & AlgorithmsModerateICPC regional · GATE CS

Problem: The Euler's totient of 36 is φ(36), the count of integers in [1, 36] coprime to 36. What is φ(36)?

  1. A. 18
  2. B. 24
  3. C. 12
  4. D. 6

Correct answer: C. 12

φ(36) = 36 · (1 − 1/2) · (1 − 1/3) = 12. Removing only the evens gives 18, removing only multiples of 3 gives 24, and multiplying by 1/2 · 1/3 instead of (1 − 1/p) gives 6.

More Coding Interview Problems questions

Exams that ask this topic