- import java.util.Scanner;
- public class Ch01 {
- public static void main(String[] args) {
- // TODO 自動產生的方法 Stub
- int a,b;
- try{
- Scanner sc=new Scanner(System.in);
- a=sc.nextInt();
- b=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)
- }
-
- }
- }
複製代碼 |