get-hcf
v1.0.0
Published
Compute the Highest Common Factor (HCF / GCD) of two integers
Maintainers
Readme
get-hcf
A lightweight utility to calculate the Highest Common Factor (HCF), also known as the Greatest Common Divisor (GCD), of two integers.
Installation
npm install get-hcfor with Yarn:
yarn add get-hcfUsage
const getHCF = require('get-hcf');
getHCF(40, 48); // 8
getHCF(12, 18); // 6
getHCF(7, 13); // 1API
getHCF(a, b)
| Parameter | Type | Description |
| --------- | -------- | ------------------------ |
| a | number | A positive integer |
| b | number | A positive integer |
Returns: number — the highest common factor of a and b.
Testing
Tests use Node's built-in assert module and require no extra dependencies.
npm testLicense
ISC
