PHP gmp_jacobi()函数
gmp_jacobi()函数是一个内置函数,它以两个GMP数字$numbers1
和$numbers2
作为输入,并生成Jacobi符号。$numbers2
应是奇数且正值。
语法
以下语法显示了PHP GMP Jacobi符号函数。
gmp_jacobi (numbers1,numbers2);
参数
- 该函数接受两个必需参数
$number1
和$number2
,如上述语法所示。 - 在PHP版本5.6及以上的gmp_jacobi()函数中,这些参数可以是GMP对象。
- 只要能够将字符串转换为数字,它们也可以是数字字符串。
返回值
该函数显示一个GMP数字或GMP对象(PHP 5.6及以上版本),即这些数字的雅可比符号。
示例
以下示例显示了不同数字和GMP参数的雅可比符号。
示例1: 给定的代码显示了正数的雅可比符号。
<!DOCTYPE html>
<html>
<body>?
<h4> PHP gmp_jacobi() Function </h4>
<?php
echo "<p> Display Jacobi symbol of the given parameters. </p>";
value1 = gmp_jacobi(11, 3);value2 = gmp_jacobi(128, 7);
value3 = gmp_jacobi(157, 129);value4 = gmp_jacobi(150, 5);
echo "The Jacobi symbol of the GMP numbers: ".value1."<br>";
echo "<br/>";
echo "The Jacobi symbol of the GMP numbers: ".value2."<br>";
echo "<br/>";
echo "The Jacobi symbol of the GMP numbers: ".value3."<br>";
echo "<br/>";
echo "The Jacobi symbol of the GMP numbers: ".value4."<br>";
?>
</body>
</html>
输出:
该图像显示了给定两个值的雅各比符号。
示例2: 给定的代码显示所需参数和负参数的雅可比符号。我们可以看到输出值在负参数的情况下有所不同。
<!DOCTYPE html>
<html>
<body>
<h4> PHP gmp_jacobi() Function </h4>
<?php
echo "<p> Display Jacobi symbol of the given parameters. </p>";
value1 = gmp_jacobi(-11, 3);value2 = gmp_jacobi(128, -7);
value3 = gmp_jacobi(-157, -129);value4 = gmp_jacobi(150, -11);
echo "The Jacobi symbol of the GMP numbers: " .value1."<br>";
echo "<br/>";
echo "The Jacobi symbol of the GMP numbers:" .value2."<br>";
echo "<br/>";
echo "The Jacobi symbol of the GMP numbers: " .value3."<br>";
echo "<br/>";
echo "The Jacobi symbol of the GMP numbers: " .value4."<br>";
?>
</body>
</html>
输出:
该图像显示了给定两个数值的雅可比符号。
示例3: 下面的示例显示了具有可变参数及其值的gmp_jacobi()函数
<!DOCTYPE html>
<html>
<body>
<h4> PHP gmp_jacobi() Function </h4>
<?php
echo "<p> Display the Jacobi symbol of the given parameters. </p>";
var_value1 = "11";var_value2 = "121";
var_value3 = "7";var_value4 = "131";
value1 = gmp_jacobi(var_value1, var_value3);value2 = gmp_jacobi(var_value2,var_value3);
value3 = gmp_jacobi(var_value4, var_value2);
echo "The Jacobi symbol of the GMP numbers: " .value1."<br>";
echo "<br/>";
echo "The Jacobi symbol of the GMP numbers:" .value2."<br>";
echo "<br/>";
echo "The Jacobi symbol of the GMP numbers: " .value3."<br>";
?>
</body>
</html>
输出:
该图像显示了给定值的雅可比符号。
示例4: 下面的示例演示了使用GMP参数和其值的gmp_jacobi()函数。
<!DOCTYPE html>
<html>
<body>
<h4> PHP gmp_jacobi() Function </h4>
<?php
echo "<p> Display the Jacobi symbol of the given parameters. </p>";
var_value1 = "11";var_value2 = "121";
var_value3 = "7";var_value4 = "131";
gmp_var1 = gmp_abs(var_value1);
gmp_var2 = gmp_com(var_value3);
gmp_var3 = gmp_init(var_value3);
value1 = gmp_jacobi(var_value1, gmp_var2);value2 = gmp_jacobi(var_value2,gmp_var1);
value3 = gmp_jacobi(var_value4, gmp_var3);
echo "The Jacobi symbol of the GMP numbers: " .value1."<br>";
echo "<br/>";
echo "The Jacobi symbol of the GMP numbers:" .value2."<br>";
echo "<br/>";
echo "The Jacobi symbol of the GMP numbers: " .value3."<br>";
?>
</body>
</html>
输出:
该图显示了给定值的雅可比符号。
结论
gmp_jacobi()函数显示给定值的雅可比符号。参数值必须为奇数以使用该函数工作GMP雅可比操作。