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 intcalculate(int... ints) Returns the greatest common divisor of the given integersstatic longcalculate(long... longs) Returns the greatest common divisor of the given long integersstatic BigIntegercalculate(BigInteger... bigs) Returns the greatest common divisor of the givenBigIntegersstatic PositiveIntegercalculate(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, waitMethods 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.FunctionApplies the function to the given input element x and returns its corresponding output element- Specified by:
applyin 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 givenBigIntegers- Parameters:
bigs- the integers- Returns:
- the integers' greatest common divisor
-