Package de.hdm_stuttgart.mi.sd1.gcd
Class Math
java.lang.Object
de.hdm_stuttgart.mi.sd1.gcd.Math
Computing the least common multiple and the greatest common divisor.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic long
getGcd
(long a, long b) Retrieve the greatest common divisor (GCD) of two non-zero integer values.static long
getLeastCommonMultiple
(long a, long b) The least common multiple of two given non-zero values.
-
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 valueb
- 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 valueb
- The second value- Returns:
- The common multiple of two given values.
-