The gmp_legendre() function calculates the Legendre symbol of two GMP numbers.
It returns −
- GMP number− PHP 5.5 and earlier, or
- GMP object− PHP 5.6 and later
Syntax
gmp_legendre(n1, n2)
Parameters
n1 − The first GMP number. It can be GMP object in PHP version 5.6 and later. Can also be numeric strings.
n2 − The second GMP number. It can be GMP object in PHP version 5.6 and later. Can also be numeric strings.
Return
The gmp_legendre() function returns a GMP number or object.
Example
The following is an example −
<?php $n1 = 5; $n2 = 5; echo gmp_legendre($n1, $n2); ?>
Output
The following is the output −
0
Example
Let us see another example −
<?php $n1 = 4; $n2 = 3; echo gmp_legendre($n1, $n2); ?>
Output
The following is the output −
1