View Code of Problem 66

#include<stdio.h>
int x(int a,int b){
	int c=b%a;
	while(c!=0){
		b=a;
		a=c;
		c=b%a;
		
	}
	return a;
	
}



int main(){
int a,b;




while(~scanf("%d %d",&a,&b)&&a<=b){
	if(a==b){
			printf("1\n");
		}
else{
	int m=x(a,b);
	if(m!=1){
		a=a/m;
		b=b/m;
		
	}

	printf("%d/%d\n",a,b);	
	
	
}

	}
	
	
	
	
	
	return 0;
}

Double click to view unformatted code.


Back to problem 66