ProgrammingVery hardJEE Advanced · CAT placement

What is printed?

What is printed?
x = 2**32 + 5
print((x * 0x9E3779B1) & 0xFFFFFFFF, (5 * 0x9E3779B1) & 0xFFFFFFFF)
  1. A. 387276917 387276917
  2. B. 387276917 3907690379
  3. C. 2654435761 387276917
  4. D. 387276918 387276917

Correct answer: A. 387276917 387276917

Masking with 0xFFFFFFFF keeps only the low 32 bits, and 2**32 contributes nothing to those bits. So the two expressions agree, and 5 * 0x9E3779B1 is 387276917 modulo 2**32.

More Python Programming questions

Exams that ask this topic