php man page for gmp_gcdext

Query: gmp_gcdext

OS: php

Section: 3

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

GMP_GCDEXT(3)								 1							     GMP_GCDEXT(3)

gmp_gcdext - Calculate GCD and multipliers

SYNOPSIS
array gmp_gcdext (GMP $a, GMP $b)
DESCRIPTION
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
PARAMETERS
o $a -Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6 and later, or a numeric string provided that it is possible to convert the latter to a number. o $b -Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6 and later, or a numeric string provided that it is possible to convert the latter to a number.
RETURN VALUES
An array of GMP numbers.
EXAMPLES
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); $check_gcd = (gmp_strval($g) == gmp_strval($r['g'])); $eq_res = gmp_add(gmp_mul($a, $r['s']), gmp_mul($b, $r['t'])); $check_res = (gmp_strval($g) == gmp_strval($eq_res)); if ($check_gcd && $check_res) { $fmt = "Solution: %d*%d + %d*%d = %d "; printf($fmt, gmp_strval($a), gmp_strval($r['s']), gmp_strval($b), gmp_strval($r['t']), gmp_strval($r['g'])); } else { echo "Error while solving the equation "; } // output: Solution: 12*2 + 21*-1 = 3 ?> PHP Documentation Group GMP_GCDEXT(3)
Related Man Pages
gmp_clrbit(3) - php
gmp_init(3) - php
gmp_random(3) - php
gmp_strval(3) - php
math::gmp(3pm) - debian
Similar Topics in the Unix Linux Community
Pat Townsend&#39;s Encryption Solution Certified Across All Major ... - IT Jungle
Library linking with GMP
Home Sitting Solution+919878377317 business problem solution tantrik
Home Sitting Solution+&#9320;&#9312;&#9320;&#9319;&#9318;&#9319;(3)&#9318;&#9318;(3)&#9312;&#9318; vashikaran specialist tantrik
Strange error on 285 IBM intellistation