<?php
int gmp_jacobi ( GMP|int|string $num1,
GMP|int|string $num2 )
where,
$num1 = The GMP number along top
$num2 = The GMP number along left side
?>
<?php $pa01 = [ 1, 3, 5, 7, 9, 11, 13, 15, 17 ]; ?>
<table width="100%" cellspacing="5" cellpadding="5"
border="1" align="center">
<tbody><tr><td>p\a</span></td><td>0</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td></tr>
<?php foreach ($pa01 as $p01)
{
echo '<tr>';
?>
<td>
<?php echo $p01; ?></td>
<?php
for($a01 = 0; $a01 <= 16; $a01++)
{
$j01 = gmp_jacobi($a01, $p01);
echo '<td>' . $j01 . '</td>';
}
}
?>
</tr><tr><td colspan="19">ed48</td></tbody></tr></table>
Jacobi symbol | ||||||||||||||||||
p\a | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | |
1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | |
3 | 0 | 1 | -1 | 0 | 1 | -1 | 0 | 1 | -1 | 0 | 1 | -1 | 0 | 1 | -1 | 0 | 1 | |
5 | 0 | 1 | -1 | -1 | 1 | 0 | 1 | -1 | -1 | 1 | 0 | 1 | -1 | -1 | 1 | 0 | 1 | |
7 | 0 | 1 | 1 | -1 | 1 | -1 | -1 | 0 | 1 | 1 | -1 | 1 | -1 | -1 | 0 | 1 | 1 | |
9 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | |
11 | 0 | 1 | -1 | 1 | 1 | 1 | -1 | -1 | -1 | 1 | -1 | 0 | 1 | -1 | 1 | 1 | 1 | |
13 | 0 | 1 | -1 | 1 | 1 | -1 | -1 | -1 | -1 | 1 | 1 | -1 | 1 | 0 | 1 | -1 | 1 | |
15 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | -1 | 1 | 0 | 0 | -1 | 0 | -1 | -1 | 0 | 1 | |
17 | 0 | 1 | 1 | -1 | 1 | -1 | -1 | -1 | 1 | 1 | -1 | -1 | -1 | 1 | -1 | 1 | 1 | |
ed48 |
<?php
for ($i = -1; $i < 10; $i++) {
var_dump(gmp_strval(gmp_jacobi(($i*$i)-1, 3)));
echo '<br>';
}
var_dump(gmp_strval(gmp_jacobi(7, 23)));
echo '<br>';
var_dump(gmp_strval(gmp_jacobi("733535124", "1234123423434535623")));
echo '<br>';
var_dump(gmp_strval(gmp_jacobi(3, "1234123423434535623")));
echo '<br>';
$n = "123123";
$n1 = "1231231";
var_dump(gmp_strval(gmp_jacobi($n, $n1)));
echo '<br>';
var_dump(gmp_strval(gmp_jacobi($n, 3)));
echo '<br>';
var_dump(gmp_strval(gmp_jacobi(3, $n1)));
echo '<br>';
try {
var_dump(gmp_jacobi(3, array()));
} catch (\TypeError $e) {
echo $e->getMessage() . "<br><br>";
}
try {
var_dump(gmp_jacobi(array(), 3));
} catch (\TypeError $e) {
echo $e->getMessage() . "<br><br>";
}
try {
var_dump(gmp_jacobi(array(), array()));
} catch (\TypeError $e) {
echo $e->getMessage() . "<br><br>";
}
?>