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)?
- A. 18
- B. 24
- C. 12
- 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
- Problem: A pair of ropes is connected as a chain: lengths 3, 4, 5 are joined in the order listed, each join costs the sum of the two…
- Problem: From the list [5, 3, 3, 7, 12, 9], what is the second-smallest distinct value (duplicates count once)?
- Problem: In the array [1, −2, 3, −4, 5, −6], how many contiguous subarrays have a sum of exactly 0?
- Problem: The mapping of letters is A=1 through Z=26. What is the sum of the values of the letters in the word "MATH"?
- Problem: The number of ways to choose 4 people from 9 so that a specific two people are never both chosen is what value?
- Problem: How many integers in [1, 10^4] are divisible by 3 and have an odd number of digits? Run the code. python print(sum(1 for x in…