def testJacobiSymbolWithAEqualToZero(): for x, expected in zip(range(1, 12, 2), [1, 0, 0, 0, 0, 0]): assert jacobi_symbol(0, x) == expected
def testJacobiSymbolWithAEqualToOne(): for x, expected in zip(range(3, 12, 2), [1, 1, 1, 1, 1]): assert jacobi_symbol(1, x) == expected
def D_chooser(candidate): """Choose a D value suitable for the Baillie-PSW test""" D = 5 while jacobi_symbol(D, candidate) != -1: D += 2 if D > 0 else -2 D *= -1 return D
def testJacobiSymbolWithANegative(): for x, expected in zip(range(-1, -5, -1), [-1, 1, 0, -1, 1]): assert jacobi_symbol(x, 3) == expected
def testJacobiSymbolWithAGreaterThanM(): for x, expected in zip(range(1, 12, 2), [1, 0, -1, -1, 0, 1]): assert jacobi_symbol(12, x) == expected
def testJacobiSymbolWithAEqualToTwo(): for x, expected in zip(range(3, 12, 2), [-1, -1, 1, 1, -1]): assert jacobi_symbol(2, x) == expected