PHP gmp_jacobi() Function

The gmp_jacobi() function is a built-in function that takes two GMP numbers, $numbers1 and $numbers2, as input and generates the Jacobi symbol. $numbers2 should be an odd and positive value.

Syntax

The following syntax shows the PHP GMP Jacobi symbol function.

Parameters

  • The function accepts two mandatory parameters, $number1 and $number2, as shown in the above syntax.
  • These parameters can be GMP objects in PHP versions 5.6 and above for the gmp_jacobi() function.
  • They can be numeric strings as long as it is possible to convert the strings to numbers.

Return Values

This function shows a GMP number or a GMP object (PHP 5.6 and above) that is the Jacobi of the numbers.

Examples

The following example shows the Jacobi symbol of the different numbers and GMP parameters.

Example1: the given code shows the Jacobi symbol of the essential and positive values.

Output:

The image shows the Jacobi symbol of the given two values.

PHP gmp_jacobi() function

Example2: the given code shows the Jacobi symbol of the required and negative values. We can see the difference between output values with negative parameters.

Output:

The image shows the Jacobi symbol of the given two values.

PHP gmp_jacobi() function

Example3: the following example shows the gmp_jacobi() function with variable parameter and its value

Output:

The image shows the Jacobi symbol of the given value.

PHP gmp_jacobi() function

Example4: the following example shows the gmp_jacobi() function with GMP parameter and its value

Output:

The image shows the Jacobi symbol of the given value.

PHP gmp_jacobi() function

Conclusion

The gmp_jacobi() function displays the Jacobi symbol of the given value. The parameter value must be odd to use the function to work the GMP Jacobi operation.