Ejemplo n.º 1
0
 def test_crt_without_coprime(self):
     v = random.randint(10, 10000000000)
     n = random.randint(1, 100)
     remainders = []
     moduli = []
     for i in range(n):
         mod = random.randint(2, 100000000)
         remainders.append(v % mod)
         moduli.append(mod)
     lcm = reduce(gmpy2.lcm, moduli)
     res = number.crt(remainders, moduli, False)
     self.assertEqual(res, (v % lcm, lcm))
Ejemplo n.º 2
0
 def test_crt_without_coprime(self):
     v = random.randint(10, 10000000000)
     n = random.randint(1, 100)
     remainders = []
     moduli = []
     for i in range(n):
         mod = random.randint(2, 100000000)
         remainders.append(v % mod)
         moduli.append(mod)
     lcm = reduce(gmpy2.lcm, moduli)
     res = number.crt(remainders, moduli, False)
     self.assertEqual(res, (v % lcm, lcm))
Ejemplo n.º 3
0
 def test_crt_coprime(self):
     v = random.randint(10, 10000000000)
     n = random.randint(1, 100)
     remainders = []
     moduli = []
     lcm = 1
     for i in range(n):
         while True:
             mod = random.randint(2, 100000000)
             g = gmpy2.gcd(mod, lcm)
             if g == 1: break
         remainders.append(v % mod)
         moduli.append(mod)
         lcm *= mod
     res = number.crt(remainders, moduli)
     self.assertEqual(res, (v % lcm, lcm))
Ejemplo n.º 4
0
 def test_crt_coprime(self):
     v = random.randint(10, 10000000000)
     n = random.randint(1, 100)
     remainders = []
     moduli = []
     lcm = 1
     for i in range(n):
         while True:
             mod = random.randint(2, 100000000)
             g = gmpy2.gcd(mod, lcm)
             if g == 1 : break
         remainders.append(v % mod)
         moduli.append(mod)
         lcm *= mod
     res = number.crt(remainders, moduli)
     self.assertEqual(res, (v % lcm, lcm))