Class EuclideanAlgorithm

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 Details

    • EuclideanAlgorithm

      public EuclideanAlgorithm()
  • Method Details

    • apply

      public Integer apply(PositiveInteger[] ints)
      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 interface org.zfcj.math.set.Function<PositiveInteger[],Integer>
    • calculate

      public static PositiveInteger calculate(PositiveInteger... ints)
      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

      public static BigInteger calculate(BigInteger... bigs)
      Returns the greatest common divisor of the given BigIntegers
      Parameters:
      bigs - the integers
      Returns:
      the integers' greatest common divisor