---
title: "Java求最大公约数和最小公倍数"
author: "cm1993"
date: "2016-03-17T09:34:18Z"
tags: []
categories: ["编程语言"]
slug: "java"
draft: false
lastmod: "2016-03-17T09:34:18Z"
id: 2283715
url: "https://cm1993.iteye.com/blog/2283715"
---

//最大公约数
public static int getdivisor(int a, int b)
{
	while(a!=b)
	{
		if(a>b)
			a=a-b;
		else if(a<b)
			b=b-a;
	}
	return b;
}
  1.0
 //最小公倍数
public static int getmultiple(int a,int b)
{
	int n=a*b;
	while(a!=b)
	{

		if(a>b)
			a=a-b;
		else if(a<b)
			b=b-a;
	}
	return n/b;
}