java.lang.Object
org.bzdev.math.Bezout
Compute Bézout coefficients for two integers.
The computation uses the extended Euclidean algorithm.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
gcd
(int a, int b, int[] result) Find two coefficients (s,t) such that gcd(a,b) = sa+tb for positive integers a and b.static long
gcd
(long a, long b, long[] result) Find two coefficients (s,t) such that gcd(a,b) = sa+tb for positive long integers a and b.
-
Constructor Details
-
Bezout
public Bezout()
-
-
Method Details
-
gcd
public static int gcd(int a, int b, int[] result) Find two coefficients (s,t) such that gcd(a,b) = sa+tb for positive integers a and b.- Parameters:
a
- the first integerb
- the second integerresult
- an array whose first component is s and whose second component is t, where gcd(a,b) = sa+tb- Returns:
- gcd(a,b) (the greatest common divisor of a and b)
-
gcd
public static long gcd(long a, long b, long[] result) Find two coefficients (s,t) such that gcd(a,b) = sa+tb for positive long integers a and b.- Parameters:
a
- the first integerb
- the second integerresult
- an array whose first component is s and whose second component is t, where gcd(a,b) = sa+tb- Returns:
- gcd(a,b) (the greatest common divisor of a and b)
-