gmp_legendre()函数是PHP中的一个内置函数,用于计算 勒让德符号 由两个GMP编号组成 (GNU多重精度:适用于大数字) $num1 和 $num2 作为参数传递给函数并返回它。 $num2 一定是积极的和奇怪的。
null
语法:
gmp_legendre( $num1, $num2 )
使用的参数: 该函数接受两个必需参数 $num1 和 $num2 如上面的语法所示。这些参数可以是PHP 5.6版及更高版本中的GMP对象,也可以将数字字符串传递给函数,前提是可以将这些字符串转换为数字。
返回值: 此函数返回一个GMP编号(在PHP5.5及更早版本中)或一个GMP对象(在PHP5.6及更高版本中),这是两个数字的勒让德符号。
例如:
Input : $num1 = 2, $num2 = 3 Output : -1 Input : $num1 = 6, $num2 = 15 Output : 0
下面的程序将演示gmp_legendre()函数:
方案1
<?php // PHP program to calculate the // legendre of two GMP numbers $num1 = 13; $num2 = 9907; //Display the result echo gmp_legendre( $num1 , $num2 ); ?> |
输出
1
方案2
<?php // PHP program to calculate the // legendre of two GMP numbers // creating GMP numbers using gmp_init() $num1 = gmp_init( "124567812" ); $num2 = gmp_init( "271290907" ); //Display the result echo gmp_legendre( $num1 , $num2 ); ?> |
输出
-1
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END