Data Structures & AlgorithmsHardGATE CS · TCS NQT

What is the smallest positive integer k such that k! is divisible by 2^10 = 1024?

  1. A. 10
  2. B. 12
  3. C. 20
  4. D. 7

Correct answer: B. 12

Legendre: v₂(k!) = ⌊k/2⌋ + ⌊k/4⌋ + ⌊k/8⌋ + ...; at k = 11 it is 5 + 2 + 1 = 8, at k = 12 it reaches 6 + 3 + 1 = 10. Counting only ⌊k/2⌋ gives 20, assuming v₂ = k gives 10, and 7 is the first k with k! ≥ 1024, not divisible by it.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic