Пример #1
1
def testJacobiSymbolWithAEqualToZero():
    for x, expected in zip(range(1, 12, 2), [1, 0, 0, 0, 0, 0]):
        assert jacobi_symbol(0, x) == expected
Пример #2
1
def testJacobiSymbolWithAEqualToOne():
    for x, expected in zip(range(3, 12, 2), [1, 1, 1, 1, 1]):
        assert jacobi_symbol(1, x) == expected
Пример #3
0
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
Пример #4
0
def testJacobiSymbolWithAEqualToZero():
    for x, expected in zip(range(1, 12, 2), [1, 0, 0, 0, 0, 0]):
        assert jacobi_symbol(0, x) == expected
Пример #5
0
def testJacobiSymbolWithANegative():
    for x, expected in zip(range(-1, -5, -1), [-1, 1, 0, -1, 1]):
        assert jacobi_symbol(x, 3) == expected
Пример #6
0
def testJacobiSymbolWithAGreaterThanM():
    for x, expected in zip(range(1, 12, 2), [1, 0, -1, -1, 0, 1]):
        assert jacobi_symbol(12, x) == expected
Пример #7
0
def testJacobiSymbolWithAEqualToTwo():
    for x, expected in zip(range(3, 12, 2), [-1, -1, 1, 1, -1]):
        assert jacobi_symbol(2, x) == expected
Пример #8
0
def testJacobiSymbolWithAEqualToOne():
    for x, expected in zip(range(3, 12, 2), [1, 1, 1, 1, 1]):
        assert jacobi_symbol(1, x) == expected
Пример #9
0
def testJacobiSymbolWithANegative():
    for x, expected in zip(range(-1, -5, -1), [-1, 1, 0, -1, 1]):
        assert jacobi_symbol(x, 3) == expected
Пример #10
0
def testJacobiSymbolWithAGreaterThanM():
    for x, expected in zip(range(1, 12, 2), [1, 0, -1, -1, 0, 1]):
        assert jacobi_symbol(12, x) == expected
Пример #11
0
def testJacobiSymbolWithAEqualToTwo():
    for x, expected in zip(range(3, 12, 2), [-1, -1, 1, 1, -1]):
        assert jacobi_symbol(2, x) == expected