<?php
GMP|false gmp_invert ( GMP|int|string $num1,
GMP|int|string $num2 )
where,
$num1 = The number to invert
$num2 = The modulo to be used
?>
<?php
// Run this code several times
$num01a = mt_rand(0, 100);
$num01b = mt_rand(0, 100);
// You must try other values for each mt_rand
echo "num01a = $num01a<br><br>num01b = $num01b<br><br>";
$in01 = gmp_invert($num01a, $num01b);
var_dump($in01);
echo '<br><br>';
echo "gmp_invert($num01a, $num01b) = " . gmp_strval($in01);
?>
<?php
$arr02 = [ 55, 64, '021', 21 ];
$mod02 = [ 2, 4, 11, 24, 111 ];
// You must try other values for each array
foreach($arr02 as $a02)
{
foreach($mod02 as $m02)
{
$in02 = gmp_invert($a02, $m02);
var_dump($in02);
echo '<br>gmp_invert( ' . $a02 . ', ' . $m02 . ' ) = ' .
gmp_strval($in02) .
'<br>where<br>';
echo "gmp_mod(gmp_invert($a02, $m02) * $a02, $m02) = ";
echo gmp_mod(gmp_invert($a02, $m02) * $a02, $m02) . '<br><br>';
}
}
?>
<?php
$a03 = 55;
$m03 = 111;
// You must try other values
$in03 = gmp_invert($a03, $m03);
$rs03 = gmp_strval($in03);
echo 'gmp_invert( ' . $a03 . ', ' . $m03 . ' ) = ' . $rs03 . '<br><br>';
echo 'where:<br><br>';
$cp03 = gmp_mod($rs03 * $a03, $m03);
echo 'gmp_mod( ' . $rs03 . '*' . $a03 . ', ' . $m03 . ' ) = ' . $cp03;
?>