コード例 #1
1
ファイル: test.py プロジェクト: andrewjtimmons/baillie-psw
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
ファイル: test.py プロジェクト: andrewjtimmons/baillie-psw
def testJacobiSymbolWithAEqualToOne():
    for x, expected in zip(range(3, 12, 2), [1, 1, 1, 1, 1]):
        assert jacobi_symbol(1, x) == expected
コード例 #3
0
ファイル: baillie_psw.py プロジェクト: cdusold/baillie-psw
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
ファイル: test.py プロジェクト: cheran-senthil/baillie-psw
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
ファイル: test.py プロジェクト: cheran-senthil/baillie-psw
def testJacobiSymbolWithANegative():
    for x, expected in zip(range(-1, -5, -1), [-1, 1, 0, -1, 1]):
        assert jacobi_symbol(x, 3) == expected
コード例 #6
0
ファイル: test.py プロジェクト: cheran-senthil/baillie-psw
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
ファイル: test.py プロジェクト: cheran-senthil/baillie-psw
def testJacobiSymbolWithAEqualToTwo():
    for x, expected in zip(range(3, 12, 2), [-1, -1, 1, 1, -1]):
        assert jacobi_symbol(2, x) == expected
コード例 #8
0
ファイル: test.py プロジェクト: cheran-senthil/baillie-psw
def testJacobiSymbolWithAEqualToOne():
    for x, expected in zip(range(3, 12, 2), [1, 1, 1, 1, 1]):
        assert jacobi_symbol(1, x) == expected
コード例 #9
0
ファイル: test.py プロジェクト: andrewjtimmons/baillie-psw
def testJacobiSymbolWithANegative():
    for x, expected in zip(range(-1, -5, -1), [-1, 1, 0, -1, 1]):
        assert jacobi_symbol(x, 3) == expected
コード例 #10
0
ファイル: test.py プロジェクト: andrewjtimmons/baillie-psw
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
ファイル: test.py プロジェクト: andrewjtimmons/baillie-psw
def testJacobiSymbolWithAEqualToTwo():
    for x, expected in zip(range(3, 12, 2), [-1, -1, 1, 1, -1]):
        assert jacobi_symbol(2, x) == expected