# Path: tryalgo/arithm.py
# def inv(a, p):
#     """Inverse of a in :math:`{mathbb Z}_p`
# 
#     :param a,p: non-negative integers
#     :complexity: O(log a + log p)
#     """
#     return bezout(a, p)[0] % p
# 
# def pgcd(a, b):
#     """Greatest common divisor for a and b
# 
#     :param a,b: non-negative integers
#     :complexity: O(log a + log b)
#     """
#     return a if b == 0 else pgcd(b, a % b)
# 
# def binom(n, k):
#     """Binomial coefficients for :math:`n choose k`
# 
#     :param n,k: non-negative integers
#     :complexity: O(k)
#     """
#     prod = 1
#     for i in range(k):
#         prod = (prod * (n - i)) // (i + 1)
#     return prod
# 
# def binom_modulo(n, k, p):
#     """Binomial coefficients for :math:`n choose k`, modulo p
# 
#     :param n,k: non-negative integers
#     :complexity: O(k)
#     """
#     prod = 1
#     for i in range(k):
#         prod = (prod * (n - i) * inv(i + 1, p)) % p
#     return prod


import unittest
from tryalgo.arithm import inv, pgcd, binom, binom_modulo
# coding: utf8
# jill-jênn vie et christoph dürr - 2020

# pylint: disable=missing-docstring


class TestArithm(unittest.TestCase):

    def test_inv(self):
        self.assertEqual(inv(8, 17), 15)

    def test_pgcd(self):

# Path: tryalgo/arithm.py
# def inv(a, p):
#     """Inverse of a in :math:`{mathbb Z}_p`
# 
#     :param a,p: non-negative integers
#     :complexity: O(log a + log p)
#     """
#     return bezout(a, p)[0] % p
# 
# def pgcd(a, b):
#     """Greatest common divisor for a and b
# 
#     :param a,b: non-negative integers
#     :complexity: O(log a + log b)
#     """
#     return a if b == 0 else pgcd(b, a % b)
# 
# def binom(n, k):
#     """Binomial coefficients for :math:`n choose k`
# 
#     :param n,k: non-negative integers
#     :complexity: O(k)
#     """
#     prod = 1
#     for i in range(k):
#         prod = (prod * (n - i)) // (i + 1)
#     return prod
# 
# def binom_modulo(n, k, p):
#     """Binomial coefficients for :math:`n choose k`, modulo p
# 
#     :param n,k: non-negative integers
#     :complexity: O(k)
#     """
#     prod = 1
#     for i in range(k):
#         prod = (prod * (n - i) * inv(i + 1, p)) % p
#     return prod


# Path: tests/test_arithm.py
import unittest
from tryalgo.arithm import inv, pgcd, binom, binom_modulo

# coding: utf8
# jill-jênn vie et christoph dürr - 2020

# pylint: disable=missing-docstring


class TestArithm(unittest.TestCase):

    def test_inv(self):
        self.assertEqual(inv(8, 17), 15)

    def test_pgcd(self):

        self.assertEqual(pgcd(12, 18), 6)