View Code of Problem 66

import java.util.Scanner;
public class Main {
	public static void main(String[] args) {	
		int a,b,x,a1,b1;
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()) {
			a = scan.nextInt();
			b = scan.nextInt();
			x=a;
			if(a==b) {
				System.out.println(1);
			}else {
				while(x!=0) {
					if(a%x==0 && b%x==0) {
						break;
					}
					x--;
				}			
			a1 = a/x;
			b1 = b/x;			
			System.out.println(a1+"/"+b1);
			}
		}
		scan.close();
		}
}

Double click to view unformatted code.


Back to problem 66