Here you can find the source of lcm(int a, int b)
Parameter | Description |
---|---|
a | a parameter |
b | a parameter |
public static int lcm(int a, int b)
//package com.java2s; //License from project: Open Source License public class Main { /**// ww w . j a v a2 s . c o m * @param a * @param b * @return the least common multiple of {@code a} and {@code b} */ public static int lcm(int a, int b) { return a * (b / gcd(a, b)); } /** * @param a * @param b * @return the least common multiple of {@code a} and {@code b} */ public static long lcm(long a, long b) { return a * (b / gcd(a, b)); } /** * @param a * @param b * @return the greatest common divisor of {@code a} and {@code b} */ public static int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } /** * @param a * @param b * @return the greatest common divisor of {@code a} and {@code b} */ public static long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); } }