ProgrammingHardTCS NQT · Infosys

uint64_t f = 1; for (uint64_t i = 1; i <= 21; i++) f *= i; What is f after the loop?

  1. A. 51090942171709440000
  2. B. 0
  3. C. 14197454024290336768
  4. D. 2432902008176640000

Correct answer: C. 14197454024290336768

The exact 21! is 51090942171709440000, which exceeds 2^64. Unsigned multiplication keeps the value modulo 2^64, giving 14197454024290336768. Stopping at 20! would give 2432902008176640000.

More C Programming questions

Exams that ask this topic