View Code of Problem 66

#include <iostream>
using namespace std;

int main(){
  int a,b;
  while(scanf("%d%d",&a,&b)!=EOF){
    for(int j=a;j>=2;j--){
      if(a%j==0&&b%j==0){
        a/=j;
        b/=j;
      }
    }
    if(a==b)
      printf("%d\n",1);
    else
      printf("%d/%d\n",a,b);
  }
  return 0;
}

Double click to view unformatted code.


Back to problem 66