UNPKG

@ribajs/core

Version:

Core module of Riba.js

13 lines (11 loc) 275 B
/** * Greatest common divisor (GCD) useful to calculate a ratio * @see https://stackoverflow.com/a/1186465/1465919 */ const _gcd = (a: number, b: number): number => { return b === 0 ? a : _gcd(b, a % b); }; export const gcdFormatter = { name: "gcd", read: _gcd, };