View Code of Problem 66

#include<iostream>
#include<algorithm>
using namespace std;
int gcd(int a, int b)
{
	return b == 0 ? a : gcd(b, a%b);
}
int main()
{
	int a, b;
	while (cin >> a >> b)
	{
		int k = gcd(a, b);
		if (a%b == 0)
			cout << a / b << endl;
		else
			cout << a / k << "/" << b / k << endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 66