Java gcd GCD(int m, int n)

Here you can find the source of GCD(int m, int n)

Description

GCD

License

Open Source License

Return

gcd(|m|, |n|)

Declaration

static private int GCD(int m, int n) 

Method Source Code

//package com.java2s;

public class Main {
    /**//w  ww .  ja  va 2  s  . c  o m
     * @return gcd(|m|, |n|)
     */
    static private int GCD(int m, int n) {
        if (m < 0) {
            m = -m;
        }
        if (n < 0) {
            n = -n;
        }
        if (0 == n) {
            return m;
        } else {
            return GCD(n, m % n);
        }
    }
}

Related

  1. gcd(int a, int b)
  2. gcd(int a, int b, int... rest)
  3. gcd(int firstNumber, int secondNumber)
  4. gcd(int k, int m)
  5. gcd(int largerNumber, int smallerNumber)
  6. gcd(int m, int n)
  7. gcd(int m, int n)
  8. gcd(int n, int m)
  9. gcd(int n1, int n2)