UNPKG

@mathlib/functions

Version:
14 lines (13 loc) 382 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function isOdd(n) { if (isNaN(n)) { throw new Error("n should be a number."); } const _n = typeof n === "string" ? parseFloat(n) : n; if (!Number.isInteger(_n)) { throw new Error("Fractions cannot be even or odd."); } return n % 2 !== 0; } exports.default = isOdd;