• PHP Video Tutorials

PHP - gmp_jacobi() Function



Definition and Usage

The gmp_jacobi() function calculates the jacobi symbol.

Description

The Jacobi symbol is a generalization of the Legendre symbol.

Syntax

gmp_jacobi ( GMP $a , GMP $p ) : int

Parameters

Sr.No Parameter & Description
1

a

It can a GMP resource number , a gmp object or a numeric string.

2

b

It can a GMP resource number , a gmp object or a numeric string. The value of b has to be positive and odd.

Return Values

PHP gmp_jacobi() function returns a Jacobi symbol for the given GMP number.

PHP Version

This function will work from PHP Version greater than 5.0.0.

Example 1

Working of gmp_jacobi −

<?php
   $js = gmp_jacobi("1", "3");
   echo "The Jacobi symbol of 1/3 is :".$js;
?>

This will produce following result −

The Jacobi symbol of 1/3 is :1

Example 2

Working of gmp_jacobi −

<?php
   $js = gmp_jacobi("3", "11");
   echo "The Jacobi symbol of 3/11 is :".$js;
?>

This will produce following result −

The Jacobi symbol of 3/11 is :1
php_function_reference.htm
Advertisements