gmp_gcdext() - gmp库(多精度计算)
gmp_gcdext()
(PHP 4 >= 4.0.4, PHP 5, PHP 7)
Calculate GCD and multipliers
说明
gmp_gcdext(GMP$a, GMP$b): arrayCalculates g, s, and t, such thata*s + b*t = g = gcd(a,b), where gcd is the greatest common divisor. Returns an array with respective elements g, s and t.
This function can be used to solve linear Diophantine equations in two variables. These are equations that allow only integer solutions and have the form:a*x + b*y = c. For more information, go to the »"Diophantine Equation" page at MathWorld
参数
$a可以是一个 GMP数据resouce,或一个可以转换为数值的字符串。
$b可以是一个 GMP数据resouce,或一个可以转换为数值的字符串。
返回值
An array of GMP numbers.
范例
Solving a linear Diophantine equation
The extended GCD can be used to calculate mutual modular inverses of two coprime numbers. Internally gmp_invert uses this extended GCD routine, but effectively throws away one of the inverses. If gcd(a,b)=1, then r.a+s.b=1 Therefore r.a == 1 (mod s) and s.b == 1 (mod r) Note that one of r and s will be negative, and so you'll want to canonicalise it.
鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com
图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!