Here you can find the source of gcd(int a, int b)
Parameter | Description |
---|---|
a | a parameter |
b | a parameter |
public static int gcd(int a, int b)
//package com.java2s; //License from project: Open Source License public class Main { /**//from www . j a v a2s. c o m * @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); } }