Returns the greatest common divisor of two integers
using the extended Euclidean algorithm.
Namespace:
Extreme.Mathematics
Assembly:
Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.1
public static int GreatestCommonDivisor(
int a,
int b,
out int x,
out int y
)
Public Shared Function GreatestCommonDivisor (
a As Integer,
b As Integer,
<OutAttribute> ByRef x As Integer,
<OutAttribute> ByRef y As Integer
) As Integer
public:
static int GreatestCommonDivisor(
int a,
int b,
[OutAttribute] int% x,
[OutAttribute] int% y
)
static member GreatestCommonDivisor :
a : int *
b : int *
x : int byref *
y : int byref -> int
Parameters
- a
- Type: SystemInt32
An integer. - b
- Type: SystemInt32
An integer. - x
- Type: SystemInt32
On return, the coefficient of a. - y
- Type: SystemInt32
On return, the coefficient of b.
Return Value
Type:
Int32The greatest common divisor of
a
and
b.
The coefficients x and y
are such that
xa+yb=gcd(a,b).
Reference