Example #1
0
 /**
  * @dataProvider getAdapters
  */
 public function testMultInverseModP(MathAdapterInterface $math)
 {
     for ($i = 0; $i < 100; $i++) {
         $m = rand(20, 10000);
         for ($j = 0; $j < 100; $j++) {
             $a = rand(1, $m - 1);
             if ($math->gcd2($a, $m) == 1) {
                 $inv = $math->inverseMod($a, $m);
                 $this->assertFalse($inv <= 0 || $inv >= $m || $a * $inv % $m != 1);
             }
         }
     }
 }