ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
n = 100
z, p = 0, 5
while p <= n:
z += n // p
p *= 5
print(z, len(str(__import__('math').factorial(n))) - len(str(__import__('math').factorial(n)).rstrip('0')))- A. 24 24
- B. 24 25
- C. 25 24
- D. 12 24
Correct answer: A. 24 24
Legendre's formula counts trailing zeros of 100! as 100//5 + 100//25 + 100//125 = 24, and the factorial's digit count minus its non-zero digits also gives 24. Both values agree because each trailing zero comes from one factor of 2 and one factor of 5.
More Python Programming questions
- What is printed? python n, steps = 27, 0 while n != 1: n = n // 2 if n % 2 == 0 else 3 n + 1 steps += 1 print(steps, n)
- What is printed? python x, rev = 1200, 0 while x: rev = rev 10 + x % 10 x //= 10 print(rev, int(str(1200)[::-1]), str(1200)[::-1] == '0021')
- What is printed? python print(int('zz', 36), format(1295, 'x'), int('1295', 10) == 1295, int('zz', 36) == 35 36 + 35)
- What is printed? python print([n for n in range(100, 1000) if sum(int(d) 3 for d in str(n)) == n])
- What is printed? python print(bin(37).count('1'), bin(37)[2:].count('0'), (37).bitlength() - bin(37).count('1'))
- What is printed? python x, count = 0b1011011, 0 while x: x &= x - 1 count += 1 print(count, bin(0b1011011).count('1'))