Class Math

java.lang.Object
de.hdm_stuttgart.mi.sd1.gcd.Math

public class Math extends Object
Computing the least common multiple and the greatest common divisor.
  • Constructor Details

    • Math

      public Math()
  • Method Details

    • getGcd

      public static long getGcd(long a, long b)
      Retrieve the greatest common divisor (GCD) of two non-zero integer values. Example: The GCD of 18 and 12 is 6.
      Parameters:
      a - The first non-zero integer value
      b - The second non-zero integer value
      Returns:
      The GCD of a and b
    • getLeastCommonMultiple

      public static long getLeastCommonMultiple(long a, long b)
      The least common multiple of two given non-zero values. Example: The least common multiple of 10 and 6 is 30.
      Parameters:
      a - The first value
      b - The second value
      Returns:
      The common multiple of two given values.