We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f720bc3 commit 888813fCopy full SHA for 888813f
JavaBook/NumberThoery/LCM.java
@@ -0,0 +1,18 @@
1
+public class LCM {
2
+ public static int gcd(int a, int b){
3
+ if(b==0){
4
+ return a;
5
+ }
6
+ return gcd(b, a%b);
7
8
+ public static void main(String[] args){
9
+ int a = 10;
10
+ int b = 20;
11
+ int result = lcm(a, b);
12
+ System.out.println("GCD of " + a + " and " + b + " is: " + gcd(a, b));
13
+ System.out.println("LCM of " + a + " and " + b + " is: " + result);
14
15
+ public static int lcm(int a, int b){
16
+ return (a*b)/gcd(a,b);
17
18
+}
0 commit comments