Exemplo n.º 1
0
    def compute_denominators(self, k):
        denominators = []
        temp = BigNum(1)
        for i in range(1, k + 1):
            if i == 1:
                for j in range(2, k + 1):
                    elem = i - j
                    temp = temp * elem
            elif i == k:
                elem = 1 - k
                temp = temp * elem
            else:
                inverse = BigNum(i - 1 - k)
                inverse = inverse.mod_inverse()
                elem = i - 1
                temp = temp * elem
                temp = temp * inverse
            denominators.append(temp)

        return denominators
Exemplo n.º 2
0
    def test_mod_inverse(self):
        bg = BigNum()

        self.assertEqual(bg * bg.mod_inverse(), BigNum(1))