import java.io.*;
import java.util.*;
public class JPA307 {
public static void main (String argv[]) throws IOException {
int num1, num2;
Scanner input = new Scanner(System.in);
System.out.println("Input:");
num1=input.nextInt();
while (num1!=999) {
num2=input.nextInt();
System.out.println(gcd(num1,num2));
System.out.println("Input:");
num1=input.nextInt();
}
}
static int gcd (int m, int n) {
int result;
while (n!=0){
result=m%n;
m=n;
n=result;
}
return m;
}
}
沒有留言:
張貼留言