How to use 'mdn reduce' in JavaScript

Every line of 'mdn reduce' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
22export function reduce(n: Integer, d: Natural): Rational {
23 return nonZeroInteger.fromInteger(n).fold(zero, n => {
24 const divisor = natural.gcd(nonZeroInteger.abs(n), d)
25 const n2 = integer.div(n, divisor)
26 const d2 = natural.div(d, divisor)
27 return [n2, d2]
28 })
29}

Related snippets