Click or drag to resize

EuclidExtendedGreatestCommonDivisor(Int64, Int64, Int64, Int64) Method

Computes the extended greatest common divisor, such that a*x + b*y = gcd(a,b).

Namespace: Altaxo.Calc
Assembly: AltaxoCore (in AltaxoCore.dll) Version: 4.8.3179.0 (4.8.3179.0)
Syntax
C#
public static long ExtendedGreatestCommonDivisor(
	long a,
	long b,
	out long x,
	out long y
)

Parameters

a  Int64
First Integer: a.
b  Int64
Second Integer: b.
x  Int64
Resulting x, such that a*x + b*y = gcd(a,b).
y  Int64
Resulting y, such that a*x + b*y = gcd(a,b)

Return Value

Int64
Greatest common divisor gcd(a,b)
Example
C#
long x,y,d;
d = Fn.GreatestCommonDivisor(45,18,out x, out y);
-> d == 9 && x == 1 && y == -2
The gcd of 45 and 18 is 9: 18 = 2*9, 45 = 5*9. 9 = 1*45 -2*18, therefore x=1 and y=-2.
See Also