1.0.4 โข Published 10 months ago
@gledyson/factorialjs v1.0.4
๐ฆ @gledyson/factorialjs
Simple function to calculate the factorial of non-negative integers in JavaScript.
๐ง Installation
Use npm to install:
npm install @gledyson/factorialjs
๐ Usage
Importing the module
const factorial = require('@gledyson/factorialjs');Examples
console.log(factorial(0)); // 1
console.log(factorial(1)); // 1
console.log(factorial(5)); // 120
console.log(factorial(10)); // 3628800Invalid cases
console.log(factorial(-3)); // NaN
console.log(factorial("texto")); // NaN*The function only accepts non-negative integers. Any invalid input will return NaN.
๐งช Running the tests
To run the tests, simply use:
npm test๐ License MIT ยฉ Gledyson Ferreira dos Santos