CCC '02 S2 - Fraction Action
Canadian Computing Competition: 2002 Stage 1, Junior #4, Senior #2
Many advanced calculators have a fraction feature that will simplify fractions for you.
You are to write a program that will accept for input a non-negative integer as a numerator and a positive integer as a denominator, and output the fraction in simplest form. That is, the fraction cannot be reduced any further, and the numerator will be less than the denominator. You can assume that all input numerators and denominators will produce valid fractions.
Sample Input 1
28
7Sample Output 1
4Sample Input 2
13
5Sample Output 2
2 3/5Sample Input 3
0
7Sample Output 3
0Sample Input 4
55
10Sample Output 4
5 1/2
Comments