Here you can find the source of gcd(int a, int b)
Parameter | Description |
---|---|
a | The first multiple. |
b | The second multiple. |
public static int gcd(int a, int b)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); public class Main { /**/*from www .j a va 2 s . com*/ * This method finds the greatest common divisor: The largest integer or the polynomial (monomial) of highest degree * that is an exact divisor or each of two or more integers or polynomials. * * @param a The first multiple. * * @param b The second multiple. * * @return */ public static int gcd(int a, int b) { int t; while (b != 0) { t = b; b = a % b; a = t; } return a; } }