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
广告

© . All rights reserved.