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)?
- A. 31
- B. 35
- C. 36
- 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
- Problem: Count the integers x with 1 <= x <= 1000 whose decimal digits sum to exactly 10.
- Problem: Modulo the prime p = 998244353, which value is the multiplicative inverse of 2, i.e. the x in [0, p) with 2x ≡ 1 (mod p)?
- Problem: A product of 11 matrices A1 A2 ... A11 is evaluated by choosing a full parenthesisation. How many different parenthesisations are…
- Problem: n = 10 people stand in a circle and every 3rd person is removed until one remains (counting starts at person 1 and the removed…
- Problem: Compute F(100) mod 1000 where F(0) = 0, F(1) = 1 and F(n) = F(n-1) + F(n-2). python def mul(A, B, m): return [[sum(A[i][k]…
- Problem: Count the inversions of the array [3, 1, 4, 1, 5, 9, 2, 6], where an inversion is a pair of positions i < j with a[i] > a[j]…