View Code of Problem 66

#include <stdio.h>
int isp(int a,int b){
	if(b==0) return a;
	else return isp(b,a%b);
}
int main(){
	int a,b;
	while(scanf("%d %d",&a,&b)!=EOF){
		int k=isp(a,b);
		while(a%k==0 && b%k==0){
			a/=k;
			b/=k;
			k=isp(a,b);
			if(k==1) break;
		}
		printf("%d/%d",a,b);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 66