public class mMathf
{
/// <summary>
/// 辗转 相除法 求 最大公约数
/// a / b = k
/// a % b = r
/// 原理 gcd(a,b) = gcd(b,r)
/// 具体 原理 参考
/// http://caixinhua1010.blog.163.com/blog/static/10540100920102138139141/
/// </summary>
/// <param name="max"></param>
/// <param name="min"></param>
/// <returns></returns>
public static int GCD(int paramter0, int paramter1)
{
int max = paramter0 > paramter1 ? paramter0 : paramter1;
int min = paramter0 <= paramter1 ? paramter0 : paramter1;
int t,
i = max,
j = min;
while ((max % min) != ) {
t = min;
min = max % min;
max = t;
}
return min;
}
/// <summary>
/// 求 最小公倍数
/// p0 * p1 / gcd(p0,p1)
/// </summary>
/// <param name="paramter0"></param>
/// <param name="paramter1"></param>
/// <returns></returns>
public static int LCM(int paramter0, int paramter1)
{
int gcd = GCD(paramter0, paramter1);
return paramter0 * paramter1 / gcd;
}
}