Data Structures & AlgorithmsModerateTCS NQT · ICPC regional
Problem: Compute the number of trailing zeros of 25! in base 5 (that is, how many times 5 divides 25!).
- A. 5
- B. 1
- C. 6
- D. 22
Correct answer: C. 6
Legendre: 25 // 5 + 25 // 25 = 5 + 1 = 6. Counting only multiples of 5 gives 5, counting only 25 gives 1, and 22 is the power of 2 in 25!.
More Coding Interview Problems questions
- Problem: A stack starts with the characters pushed in the order a, b, c, d. The following pops occur: pop, pop, then push e, pop. Which…
- Problem: The grid 2×3 contains the values [[1,2,3],[4,5,6]]. From the top-left cell you move right or down to the bottom-right, collecting…
- Problem: The sum of the digits of 2^15 is what value?
- Problem: How many subarrays of [2, 4, 1, 3, 6, 5] have an even sum? Run the code. python a = [2, 4, 1, 3, 6, 5] print(sum(1 for i in…
- Problem: How many integers x in [1, 999] satisfy x ≡ 2 (mod 3) and x ≡ 5 (mod 7)? Run the code. python print(sum(1 for x in range(1, 1000)…
- Problem: How many squares (k k with k >= 1) are at most 10^6? Run the code. python print(sum(1 for k in range(1, 10 6) if k k <= 10 6))…