3 Star 0 Fork 0

BESTI.IS.JAVA2018/20165306

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
GcdLcm.java 586 Bytes
Copy Edit Raw Blame History
20165306 authored 2018-04-01 17:09 +08:00 . GcdLcm
import java.util.*;
import java.util.Arrays;
public class GcdLcm{
public static int gcd(int x,int y){
int t;
while(y!=0){
t=x%y;
x=y;
y=t;
}
return x;
}
public static int lcm(int x,int y){
return (x*y)/gcd(x,y);
}
public static void main(String args []){
int a=Integer.parseInt(args[0]);
int b=Integer.parseInt(args[1]);
System.out.println("最大公约数是:"+gcd(a,b));
System.out.println("最小公倍数是:"+lcm(a,b));
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/BESTI-IS-JAVA-2018/20165306.git
git@gitee.com:BESTI-IS-JAVA-2018/20165306.git
BESTI-IS-JAVA-2018
20165306
20165306
master

Search