import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int a = sc.nextInt(); int b = sc.nextInt(); int temp; if (a == b) System.out.println(a / b); else { int m = a; int n = b; while (n != 0) { temp = m % n; m = n; n = temp; } System.out.println(a / m + "/" + b / m); } } } } |
Double click to view unformatted code.