Java lcm lcm(int a, int b)

Here you can find the source of lcm(int a, int b)

Description

lcm

License

Open Source License

Declaration

public static int lcm(int a, int b) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int lcm(int a, int b) {
        int temp = gcd(a, b);
        return temp > 0 ? (a / temp * b) : 0;
    }//from   w  ww .  j  a v  a 2 s  .c  om

    public static int gcd(int a, int b) {
        for (;;) {
            if (a == 0)
                return b;
            b %= a;
            if (b == 0)
                return a;
            a %= b;
        }
    }
}

Related

  1. lcm(int a, int b)
  2. lcm(int a, int b)
  3. lcm(int a, int b)
  4. lcm(int a, int b)
  5. lcm(int a, int b)
  6. lcm(int a, int b)
  7. lcm(int a, int b)
  8. lcm(int a, int b)
  9. lcm(int a, int b)