Data Structures & AlgorithmsVery hardProduct Company SDE · CP practice
Problem: What is the number of trailing zeros in 100! expressed in base 6 (count of factors of 6)? Run the code.
Problem: What is the number of trailing zeros in 100! expressed in base 6 (count of factors of 6)? Run the code.
n = 100
c2 = c3 = 0
for x in range(1, n + 1):
t = x
while t % 2 == 0:
c2 += 1
t //= 2
t = x
while t % 3 == 0:
c3 += 1
t //= 3
print(min(c2, c3))What is printed?- A. 48
- B. 97
- C. 18
- D. 16
Correct answer: A. 48
v₂(100!) = 97 and v₃(100!) = 48, and each 6 needs one of each, so min = 48. 97 uses the 2s, while 16 + 2 = 18 counts only multiples of 6 and 36, and 16 counts multiples of 6.
More Coding Interview Problems questions
- Problem: How many ways can you pick 2 different integers from [1, 20] whose sum is divisible by 4? Run the code. python print(sum(1 for i…
- Problem: What is the count of 3-digit numbers whose digits are all distinct and in strictly increasing order? Run the code. python…
- Problem: What is the sum of the first 100 positive integers that are not divisible by 3? Run the code. python print(sum(x for x in…
- Problem: How many distinct values does x mod 12 take over the numbers x in [1, 1000] that are not divisible by 4? Run the code. python…
- Problem: What is the length of the longest palindromic substring of 'abacdcaba'? Run the code. python s = 'abacdcaba' best = 0 for c in…
- Problem: How many integers in [1, 10000] have a digit sum that is divisible by 7? Run the code. python print(sum(1 for x in range(1…