Java examples for java.lang:Math Value
Returns the greatest common divisor of the specified value
public class Main{ /**/* w ww . ja v a 2 s . c o m*/ * Returns the greatest common divisor of the specified value * @param a * @param b * @return */ public static int euclidDivision(int a, int b) { if (m == 0 || m < n) throw new IllegalArgumentException(); if (n == 0) return m; int remain = m % n; if (remain == 0) return n; return euclidDivision(n, remain); } }