IntegerMath.GreatestCommonDivisor Method

Definition

Namespace: Extreme.Mathematics
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23

Overload List

GreatestCommonDivisor(BigInteger, BigInteger) Returns the greatest common divisor of two integers.
GreatestCommonDivisor(Decimal, Decimal) Returns the greatest common divisor of two integers.
GreatestCommonDivisor(Int16, Int16) Returns the greatest common divisor of two integers.
GreatestCommonDivisor(Int32, Int32) Returns the greatest common divisor of two integers.
GreatestCommonDivisor(Int64, Int64) Returns the greatest common divisor of two integers.
GreatestCommonDivisor(BigInteger, BigInteger, BigInteger, BigInteger) Returns the greatest common divisor of two integers using the extended Euclidean algorithm.
GreatestCommonDivisor(Decimal, Decimal, Decimal, Decimal) Returns the greatest common divisor of two integers using the extended Euclidean algorithm.
GreatestCommonDivisor(Int16, Int16, Int16, Int16) Returns the greatest common divisor of two integers using the extended Euclidean algorithm.
GreatestCommonDivisor(Int32, Int32, Int32, Int32) Returns the greatest common divisor of two integers using the extended Euclidean algorithm.
GreatestCommonDivisor(Int64, Int64, Int64, Int64) Returns the greatest common divisor of two integers using the extended Euclidean algorithm.

GreatestCommonDivisor(BigInteger, BigInteger)

Returns the greatest common divisor of two integers.
C#
public static BigInteger GreatestCommonDivisor(
	BigInteger a,
	BigInteger b
)

Parameters

a  BigInteger
An integer.
b  BigInteger
An integer.

Return Value

BigInteger
The greatest common divisor of a and b.

GreatestCommonDivisor(Decimal, Decimal)

Returns the greatest common divisor of two integers.
C#
public static decimal GreatestCommonDivisor(
	decimal a,
	decimal b
)

Parameters

a  Decimal
An integer.
b  Decimal
An integer.

Return Value

Decimal
The greatest common divisor of a and b.

GreatestCommonDivisor(Int16, Int16)

Returns the greatest common divisor of two integers.
C#
public static short GreatestCommonDivisor(
	short a,
	short b
)

Parameters

a  Int16
An integer.
b  Int16
An integer.

Return Value

Int16
The greatest common divisor of a and b.

GreatestCommonDivisor(Int32, Int32)

Returns the greatest common divisor of two integers.
C#
public static int GreatestCommonDivisor(
	int a,
	int b
)

Parameters

a  Int32
An integer.
b  Int32
An integer.

Return Value

Int32
The greatest common divisor of a and b.

GreatestCommonDivisor(Int64, Int64)

Returns the greatest common divisor of two integers.
C#
public static long GreatestCommonDivisor(
	long a,
	long b
)

Parameters

a  Int64
An integer.
b  Int64
An integer.

Return Value

Int64
The greatest common divisor of a and b.

GreatestCommonDivisor(BigInteger, BigInteger, BigInteger, BigInteger)

Returns the greatest common divisor of two integers using the extended Euclidean algorithm.
C#
public static BigInteger GreatestCommonDivisor(
	BigInteger a,
	BigInteger b,
	out BigInteger x,
	out BigInteger y
)

Parameters

a  BigInteger
An integer.
b  BigInteger
An integer.
x  BigInteger
On return, the coefficient of a.
y  BigInteger
On return, the coefficient of b.

Return Value

BigInteger
The greatest common divisor of a and b.

Remarks

The coefficients x and y are such that xa+yb=gcd(a,b).

GreatestCommonDivisor(Decimal, Decimal, Decimal, Decimal)

Returns the greatest common divisor of two integers using the extended Euclidean algorithm.
C#
public static decimal GreatestCommonDivisor(
	decimal a,
	decimal b,
	out decimal x,
	out decimal y
)

Parameters

a  Decimal
An integer.
b  Decimal
An integer.
x  Decimal
On return, the coefficient of a.
y  Decimal
On return, the coefficient of b.

Return Value

Decimal
The greatest common divisor of a and b.

Remarks

The coefficients x and y are such that xa+yb=gcd(a,b).

GreatestCommonDivisor(Int16, Int16, Int16, Int16)

Returns the greatest common divisor of two integers using the extended Euclidean algorithm.
C#
public static short GreatestCommonDivisor(
	short a,
	short b,
	out short x,
	out short y
)

Parameters

a  Int16
An integer.
b  Int16
An integer.
x  Int16
On return, the coefficient of a.
y  Int16
On return, the coefficient of b.

Return Value

Int16
The greatest common divisor of a and b.

Remarks

The coefficients x and y are such that xa+yb=gcd(a,b).

GreatestCommonDivisor(Int32, Int32, Int32, Int32)

Returns the greatest common divisor of two integers using the extended Euclidean algorithm.
C#
public static int GreatestCommonDivisor(
	int a,
	int b,
	out int x,
	out int y
)

Parameters

a  Int32
An integer.
b  Int32
An integer.
x  Int32
On return, the coefficient of a.
y  Int32
On return, the coefficient of b.

Return Value

Int32
The greatest common divisor of a and b.

Remarks

The coefficients x and y are such that xa+yb=gcd(a,b).

GreatestCommonDivisor(Int64, Int64, Int64, Int64)

Returns the greatest common divisor of two integers using the extended Euclidean algorithm.
C#
public static long GreatestCommonDivisor(
	long a,
	long b,
	out long x,
	out long y
)

Parameters

a  Int64
An integer.
b  Int64
An integer.
x  Int64
On return, the coefficient of a.
y  Int64
On return, the coefficient of b.

Return Value

Int64
The greatest common divisor of a and b.

Remarks

The coefficients x and y are such that xa+yb=gcd(a,b).

See Also