"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.multiplier = void 0;
// find a smallest integer multiplier for number to produce an integer result with some allowed error
function multiplier(number, error = 0) {
    let remaining = number;
    const coefficients = [];
    while (true) {
        const integer = Math.floor(remaining);
        remaining = 1 / (remaining - integer);
        coefficients.push(integer);
        const [, denominator] = coefficients.reduceRight(([numerator, denominator], coefficient) => [denominator + numerator * coefficient, numerator], [1, 0]);
        const multiplied = number * denominator;
        if (Math.abs(multiplied - Math.round(multiplied)) < error)
            return denominator;
    }
}
exports.multiplier = multiplier;
