package com.Phantom; import java.io.IOException;
import java.util.Scanner; public class Work3_1 {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
System.out.println("请输入两个数字");
int num1=in.nextInt();
int num2=in.nextInt();
System.out.println("最大公约数为>>>"+operation(num1,num2));
}
public static int operation(int a,int b) throws IOException {
int num=0;
for(int i=1; i<=a; i++){
if(b%i==0&&a%i==0){
num=i;
}
}
return num;
}
}
运行结果:
findBugs: