Data Structures & AlgorithmsHardProduct Company SDE · CP practice
Problem: What is the number of trailing zeros in 2025! (in decimal)? Run the code.
Problem: What is the number of trailing zeros in 2025! (in decimal)? Run the code.
n = 2025
c = 0
p = 5
while p <= n:
c += n // p
p *= 5
print(c)What is printed?- A. 405
- B. 486
- C. 505
- D. 506
Correct answer: C. 505
Legendre: 405 + 81 + 16 + 3 = 505. Counting only multiples of 5 gives 405, stopping at 25 gives 486, and the rough n/4 estimate gives 506.
More Coding Interview Problems questions
- Problem: What is the sum of all distinct prime factors of 2025? Run the code. python n = 2025 f = 2 ps = set() while f f <= n: while n % f…
- Problem: How many integers x in [1, 500] have x^2 + x + 41 prime? Run the code. python def isp(n): return n > 1 and all(n % d for d in…
- Problem: What is the length of the longest subarray of [2, 4, 6, 3, 8, 10, 12] whose elements are all even? Run the code. python a = [2…
- Problem: How many distinct values does floor(100 / i) take for i = 1 to 100? Run the code. python print(len({100 // i for i in range(1…
- Problem: What is the number of ways to write 20 as an ordered sum of the parts 1 and 2 (compositions)? Run the DP. python f = [1, 1] for i…
- Problem: How many 4-digit numbers have all digits equal to or greater than the digit before them (non-decreasing)? Run the code. python…