Data Structures & AlgorithmsHardICPC regional · Number theory round

Problem: Let phi(k) be Euler's totient (the count of integers g in [1, k] with gcd(g, k) = 1). What is phi(1) + phi(2) + ... + phi(10)?

  1. A. 31
  2. B. 35
  3. C. 36
  4. D. 32

Correct answer: D. 32

The values are 1,1,2,2,4,2,6,4,6,4 and they sum to 32. Taking phi(9) as 9 instead of 6 gives the trap 35, and dropping phi(1) gives 31.

More Coding Interview Problems questions

Exams that ask this topic