PHP - gmp_legendre() 函式



定義和用法

gmp_legendre() 函式計算勒讓德符號。

描述

gmp_legendre() 函式將返回給定 GMP 數的勒讓德符號。第二個 GMP 數 p 必須是奇數且為正數。

語法

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

引數

序號 引數和描述
1

a

它可以是 GMP 資源數字、gmp 物件或數字字串。

2

b

它可以是 GMP 資源數字、gmp 物件或數字字串。b 的值必須為正數且為奇數。

返回值

PHP gmp_legendre() 函式返回給定 GMP 數的勒讓德符號。

PHP 版本

此函式將在 PHP 5.0.0 及更高版本中執行。

示例 1

gmp_legendre() 的工作原理 -

<?php
   $ls = gmp_legendre("1", "3");
   echo "The Legendre symbol of 1/3 is :".$ls;
?>

這將產生以下結果 -

The Legendre symbol of 1/3 is :1

示例 2

gmp_legendre() 的工作原理 -

<?php
   $ls = gmp_legendre("3", "11");
   echo "The Legendre symbol of 3/11 is :".$ls;
?>

這將產生以下結果 -

The Legendre symbol of 3/11 is :1
php_function_reference.htm
廣告