ProgrammingHardGATE CS · Campus placements

uint32_t fact(uint32_t n) { return n <= 1 ? 1 : n * fact(n - 1); } What does fact(13) return?

  1. A. 6227020800
  2. B. 1932053504
  3. C. 1932053505
  4. D. 0

Correct answer: B. 1932053504

13! is 6227020800, which wraps modulo 2^32 to 6227020800 - 4294967296 = 1932053504. The unsigned type makes this defined, but the value is not the true factorial.

More C Programming questions

Exams that ask this topic