Data Structures & AlgorithmsModerateProduct Company SDE · CP practice
Problem: What is the number of trailing zeros of 25 40 125? Run the code.
Problem: What is the number of trailing zeros of 25 * 40 * 125? Run the code.
n = 25 * 40 * 125
c = 0
while n % 10 == 0:
n //= 10
c += 1
print(c)What is printed?- A. 3
- B. 4
- C. 2
- D. 5
Correct answer: A. 3
Count paired 2s and 5s: 25 · 40 · 125 = 5² · (2³ · 5) · 5³ = 2³ · 5⁶, so only three 10s form and the product 125000 ends in 3 zeros. Counting the six 5s gives 6, but each zero also needs a 2.
More Coding Interview Problems questions
- Problem: How many integer pairs (x, y) with 1 <= x <= 10 and 1 <= y <= 10 satisfy x y being a perfect cube? Run the code. python…
- Problem: What is the longest run of consecutive integers that all have at least one divisor in common with 30 (gcd greater than 1)…
- Problem: How many integers in [1, 500] are divisible by 4 or by 6 but not by 12? Run the code. python print(sum(1 for x in range(1, 501)…
- Problem: What is the sum of the first 12 terms of the sequence an = n^2 + 1 (n from 1 to 12)? Run the code. python print(sum(n n + 1 for n…
- Problem: How many 4-letter words over {x, y, z} contain at least one letter from each of the three symbols? Run the code. python from…
- Problem: What is the number of integers x in [1, 200] for which x^2 + 2x + 1 is divisible by 7? Run the code. python print(sum(1 for x in…