Functions
Function-48
Function-49
Function-50
~/algor $ cat problems/funksiya-kasrni-qisqartirish
Reducing a fraction
Easy
1000 ms
128 MB
33%
Write a function Reduce(p, q) that reduces the fraction $\frac{p}{q}$ and returns the result as a string "numerator/denominator". To reduce a fraction, the numerator and the denominator are divided by their greatest common divisor.
Example 1: Reduce(6, 8) → "3/4"
Example 2: Reduce(10, 5) → "2/1" — a whole number is written as a fraction too.
Write only the function body.
Input
One line with two positive integers $p$ and $q$ — the arguments of the function.
Output
The string returned by the function: the reduced fraction, e.g. 3/4.
Note
$1 \le p, q \le 10^{15}$
Examples
Input #1
6 8
Output #1
3/4
Input #2
10 5
Output #2
2/1