Skip to content
This repository was archived by the owner on Oct 23, 2018. It is now read-only.

Add LCM calculating for Mathematics module. #2321

Merged
merged 2 commits into from
Oct 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Java/Mathematics/LCM.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package Mathematics;

import static Mathematics.EuclidGCD.gcd;

/**
* Calculates lowest common multiple for given integer numbers
*/
public class LCM {
public static void main(String[] args) {
System.out.println(lcm(2, 5));
System.out.println(lcm(15, 3));
System.out.println(lcm(75, 10));
}

public static int lcm(int a, int b) {
return a * b / gcd(a, b);
}

}