Functions
Function-49
Function-50
Recursion-01
~/algor $ cat problems/funksiya-kasrlar-yigindisi
Sum of two fractions
Easy
1000 ms
128 MB
33%
Write a function AddFractions(a, b, c, d) that returns the sum of the fractions $\frac{a}{b}$ and $\frac{c}{d}$ as a reduced fraction — a string "numerator/denominator".
$$\frac{a}{b} + \frac{c}{d} = \frac{a * d + c * b}{b * d}$$
Example 1: AddFractions(1, 2, 1, 3) → "5/6"
Example 2: AddFractions(1, 4, 3, 4) → "1/1" — $\frac{1}{4} + \frac{3}{4} = 1$, a whole number is written as a fraction too.
Write only the function body.
Input
One line with four positive integers $a$, $b$, $c$ and $d$ — the arguments of the function.
Output
The string returned by the function: the reduced fraction, e.g. 5/6.
Note
$1 \le a, b, c, d \le 10^{6}$
Examples
Input #1
1 2 1 3
Output #1
5/6
Input #2
1 4 3 4
Output #2
1/1