Java Divisor maxCommonDivisor(int num1, int num2)

Here you can find the source of maxCommonDivisor(int num1, int num2)

Description

max Common Divisor

License

Open Source License

Declaration

public static int maxCommonDivisor(int num1, int num2) 

Method Source Code

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

public class Main {

    public static int maxCommonDivisor(int num1, int num2) {
        return num1 >= num2 ? maxCommonDivisorCore(num1, num2) : maxCommonDivisorCore(num2, num1);
    }/*from   w w w .  j  a v  a 2 s  . c o  m*/

    private static int maxCommonDivisorCore(int num1, int num2) {
        if (num1 % num2 == 0) {
            return num2;
        }

        return maxCommonDivisorCore(num2, num1 % num2);
    }
}

Related

  1. maxCommonDivisor(int m, int n)
  2. maxCommonDivisorCore(int num1, int num2)
  3. maxDivisibleNumber(float yourDividend, float divisor)
  4. maxLiteralLengthDivision(int n)