Skip to content

Instantly share code, notes, and snippets.

@TPAKC
Created April 23, 2015 07:46
Show Gist options
  • Save TPAKC/175f48152924988e00d3 to your computer and use it in GitHub Desktop.
Save TPAKC/175f48152924988e00d3 to your computer and use it in GitHub Desktop.
import java.util.*;
import java.io.IOException;
public class Main {
public static void main (String[] args) throws IOException
{
Scanner in = new Scanner(System.in);
long n = in.nextLong(),m = in.nextLong();
System.out.println(lcm(n,m));
}
public static long lcm(long a,long b){
return a / gcd(a,b) * b;
}
public static long gcd(long a,long b){
return b == 0 ? a : gcd(b,a % b);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment