Here you can find the source of lcm(long a, long b)
public static long lcm(long a, long b)
//package com.java2s; public class Main { public static long lcm(long a, long b) { return a * b / gcd(a, b); }// w w w . ja va2 s .co m public static int lcm(int a, int b) { return (int) lcm((long) a, (long) b); } public static short lcm(short a, short b) { return (short) lcm((long) a, (long) b); } public static byte lcm(byte a, byte b) { return (byte) lcm((long) a, (long) b); } public static long gcd(long a, long b) { long r = a; a = Math.max(a, b); b = Math.min(r, b); r = b; while (a % b != 0) { r = a % b; a = b; b = r; } return r; } public static int gcd(int a, int b) { return (int) gcd((long) a, (long) b); } public static short gcd(short a, short b) { return (short) gcd((long) a, (long) b); } public static byte gcd(byte a, byte b) { return (byte) gcd((long) a, (long) b); } public static float max(float... fs) { float max = 0; if (fs.length > 0) { max = fs[0]; for (float f : fs) { if (f > max) { max = f; } } } return max; } public static double max(double... ds) { double max = 0; if (ds.length > 0) { max = ds[0]; for (double d : ds) { if (d > max) { max = d; } } } return max; } }