Calculates g, s, and t, such that a*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
Example 1. Solving a linear Diophantine equation
<?php // Solve the equation a*s + b*t = g
// where a = 12, b = 21, g = gcd(12, 21) = 3 $a=gmp_init(12); $b=gmp_init(21); $g=gmp_gcd($a,$b); $r=gmp_gcdext($a,$b);
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest (c) 2004-2012 by phpnuker.de.