#include #include typedef long long longnum; // greatest common divisor longnum gcd(longnum a, longnum b) { while ( b > 0 ) { longnum t = b; b = a % b; a = t; } return a; } int main(int argc, char* argv[]) { if ( argc <= 2 ) return printf("usage: simplify a b\n"); longnum num = atoll(argv[1]); longnum den = atoll(argv[2]); printf("%lli/%lli = ", num, den); num /= gcd(num, den); den /= gcd(num, den); printf("%lli/%lli\n", num, den); return 0; }