All problems
Multiplicative Inverse mod 26
Problem
Return the multiplicative inverse of a modulo 26, meaning the x in 1..25 with (a * x) % 26 == 1. Return -1 when no inverse exists.
Hint
An inverse exists exactly when gcd(a, 26) = 1.
Test cases
case 1
in: [1]
expected: 1
case 2
in: [3]
expected: 9
case 3
in: [5]
expected: 21
case 4
in: [2]
expected: -1
case 5
in: [15]
expected: 7
case 6
in: [11]
expected: 19
Starter codePython
def mod_inverse_26(a):
# Your code here
pass6 test cases · run your code against them in the editor