UNPKG

@yetnt/ump

Version:

A very useless math package for your complex javascript projects

23 lines 549 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.gcd = void 0; /** * Greatest Common Divider * @param a 1st number * @param b 2nd number */ function gcd(a, b) { // Ensure a and b are positive integers a = Math.abs(Math.floor(a)); b = Math.abs(Math.floor(b)); // Find the GCD using the Euclidean algorithm while (b !== 0) { const temp = b; b = a % b; a = temp; } // Return the calculated GCD return a; } exports.gcd = gcd; //# sourceMappingURL=Gcd.js.map