Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
LCM of 2 numbers
//'main' method must be in a class 'Rextester'. //openjdk version '11.0.5' import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { int a=2,b=3; int max=a,gcd=-1; if(b>a){ max=b; } for(int i=2;i<b;i++){ if(a%i==0 && b%i==0){ gcd=i; } } if(gcd<0){ System.out.println("No LCM!"); return; } int lcm=(a*b)/gcd; System.out.println(lcm); } }
run
|
edit
|
history
|
help
0
nth fibonacci ( memoization )
pattern of the day (code formatting fixed)
JAVA # EN UZUN CÜMLEYİ EKRANA YAZDIRMA
2A
Java Q4
Prime Factors
Main.java
Binary Tree ZigZag Traversal
Zombie virus
Coding Challenge - 01 (Even numbers)