java.lang.Object
org.zfcj.math.numbers.EuclideanAlgorithm
- All Implemented Interfaces:
org.zfcj.math.set.Function<PositiveInteger[],
,Integer> org.zfcj.math.set.relation.BinaryRelation<PositiveInteger[],
Integer>
public class EuclideanAlgorithm
extends Object
implements org.zfcj.math.set.Function<PositiveInteger[],Integer>
The Euclidean Algorithm is an efficient method for computing the (GCD)
greatest common divisor of a set of integers
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply
(PositiveInteger[] ints) Applies the function to the given input element x and returns its corresponding output elementstatic int
calculate
(int... ints) Returns the greatest common divisor of the given integersstatic long
calculate
(long... longs) Returns the greatest common divisor of the given long integersstatic BigInteger
calculate
(BigInteger... bigs) Returns the greatest common divisor of the givenBigInteger
sstatic PositiveInteger
calculate
(PositiveInteger... ints) Returns the greatest common divisor of the given PositiveIntegersMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.zfcj.math.set.Function
aRb
-
Constructor Details
-
EuclideanAlgorithm
public EuclideanAlgorithm()
-
-
Method Details
-
apply
Description copied from interface:org.zfcj.math.set.Function
Applies the function to the given input element x and returns its corresponding output element- Specified by:
apply
in interfaceorg.zfcj.math.set.Function<PositiveInteger[],
Integer>
-
calculate
Returns the greatest common divisor of the given PositiveIntegers- Parameters:
ints
-- Returns:
-
calculate
public static int calculate(int... ints) Returns the greatest common divisor of the given integers- Parameters:
ints
- the integers- Returns:
- the integers' greatest common divisor
-
calculate
public static long calculate(long... longs) Returns the greatest common divisor of the given long integers- Parameters:
longs
- the integers- Returns:
- the integers' greatest common divisor
-
calculate
Returns the greatest common divisor of the givenBigInteger
s- Parameters:
bigs
- the integers- Returns:
- the integers' greatest common divisor
-