Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-152

Affine Key Valid

Problem

Return True when the affine multiplier a is invertible modulo 26, that is, when gcd(a, 26) = 1. Otherwise the cipher is not a bijection and cannot be decrypted uniquely.

Hint

The valid multipliers are coprime to 26, so even and 13-multiples fail.

Test cases

case 1
in: [1]
expected: true
case 2
in: [3]
expected: true
case 3
in: [2]
expected: false
case 4
in: [13]
expected: false
case 5
in: [25]
expected: true
Starter codePython
import math
def affine_key_valid(a):
    # Your code here
    pass

5 test cases · run your code against them in the editor