ProgrammingVery hardJEE Main · CAT placement

What is printed?

What is printed?
print(pow(3, -1, 8))
try:
    print(pow(4, -1, 8))
except ValueError:
    print('not invertible')
  1. A. 3 not invertible
  2. B. 3 4
  3. C. 5 not invertible
  4. D. 3 0

Correct answer: A. 3 not invertible

3 is its own inverse mod 8 because 3 * 3 = 9 is 1 mod 8. 4 shares a factor with 8, so pow(4, -1, 8) raises ValueError: base is not invertible for the given modulus.

More Python Programming questions

Exams that ask this topic