randFromArray([1, -1]) NEG1 === -1 ? "-" : "" randRange(1, 9) randRange(2, 9) randFromArray([1, -1]) NEG2 === -1 ? "-" : "" randRange(1, 9) randRange(2, 9) getGCD( N1, N2 ) N1 / GCD1 N2 / GCD1 getGCD( D1, D2 ) D1 / GCD2 D2 / GCD2
Reduce to lowest terms:

\displaystyle NEG1S \frac{N1}{D1} \div NEG2S \frac{N2}{D2} = {?}

(NEG1 * N1 * NEG2 * D2) / (D1 * N2)

Turn into a multiplication problem:

\displaystyle {} = NEG1S \frac{N1}{D1} \times NEG2S \frac{D2}{N2}

Reduce terms with common factors:

\displaystyle {} = NEG1S \frac{SIMP_N1}{SIMP_D1} \times NEG2S \frac{SIMP_D2}{SIMP_N2}

Combine into one fraction:

\displaystyle {} = \frac{NEG1 * SIMP_N1 \times NEG2 * SIMP_D2}{SIMP_D1 \times SIMP_N2}

Simplify:

\displaystyle {} = fractionReduce(NEG1 * N1 * NEG2 * D2, D1 * N2)