Data Structures & AlgorithmsHardICPC regional · GATE CS
Problem: What is the smallest positive integer n such that n! is divisible by 10⁶ (that is, n! has at least six trailing zeros in base 10)?
- A. 30
- B. 24
- C. 25
- D. 6
Correct answer: C. 25
Trailing zeros are limited by factors of 5: v₅(24!) = 4, while v₅(25!) = 5 + 1 = 6 because 25 contributes two 5s, so n = 25. Assuming each multiple of 5 adds exactly one zero gives 6 × 5 = 30, 24 is the last n with too few, and 6 is the number of zeros, not n.
More Coding Interview Problems questions
- Problem: Children stand in a line with ratings [1, 0, 2]. Each child gets at least one candy, and a child with a higher rating than a…
- Problem: Find the maximum amount of water held between two vertical lines of heights [1, 8, 6, 2, 5, 4, 8, 3, 7] (the water is limited by…
- Problem: What is the largest integer x with x² ≤ 2,000,000,000 (the floor of the square root of 2 × 10⁹)?
- Problem: What is the sum of the first 50 odd positive integers (1 + 3 + 5 + … + 99)?
- Problem: In a binary-tree-free DFS on the undirected graph with edges 0-1, 0-2, 1-3, 2-4, 3-4, 4-5, starting from vertex 0 and always…
- Problem: What does the following print? python print(sorted(['b', 'B', 'a', 'A']))