ProgrammingVery hardJEE Advanced · CAT placement

What is printed?

What is printed?
print(pow(2, 10**18, 10**9 + 7) == pow(2, 10**18 % (10**9 + 6), 10**9 + 7))
  1. A. True
  2. B. False
  3. C. ValueError
  4. D. 1

Correct answer: A. True

Fermat's little theorem says exponents of 2 can be reduced modulo p - 1 when p = 10**9 + 7 is prime and 2 is not a multiple of p. So both sides give the same residue.

More Python Programming questions

Exams that ask this topic