ProgrammingVery hardProduct-company MCQ pattern

What is printed on the first line?

What is printed on the first line?
M = 10**9 + 7
print((-1) % M, (2**62) % M, pow(3, M - 2, M) * 3 % M)
print(((-5) % 3) * ((-5) % 3), (-5 * -5) % 3)
  1. A. 1000000006 145586002 0
  2. B. 1000000007 145586002 1
  3. C. 1000000006 145586002 1
  4. D. 1000000006 145586003 1

Correct answer: C. 1000000006 145586002 1

(-1) % M is M - 1, and pow(3, M - 2, M) is the modular inverse of 3 by Fermat's little theorem, so multiplying by 3 gives 1 mod M.

More Python Programming questions

Exams that ask this topic