- import java.util.Scanner;
- public class JPA02 {
- public static void main(String[] args) {
- int a,b;
- try {
- Scanner sc=new Scanner(System.in);
- b=sc.nextInt();
- a=sc.nextInt();
- if(a>100 || a<1||b>100||b<1){
- System.out.println("error");
- return;
- }
- } catch (Exception e) {
- System.out.println("error");
- return;
- }
- while(a%b!=0){
- int temp=a%b;
- a=b;
- b=temp;
- }
- System.out.println(b);
- }
- }
複製代碼 |