math-utils-fast
v1.0.3
Published
this is maths tool npm package
Readme
🧮 math-utils-fast
A lightweight and efficient utility library for performing common mathematical operations in JavaScript.
✨ Features
- Basic Math Functions:
gcd,lcm,digitSum,factorial - Advanced Functions:
gcdArray,isPrime,lcmArray,allFactors - Prime Functions:
primeFactors,primeNumbers
📦 Installation
# Using npm
npm install math-utils-fast
# Using yarn
yarn add math-utils-fast🚀 Usage
CommonJS (JavaScript)
const { factorial, isPrime, lcm, gcd } = require('math-utils-fast');
console.log(factorial(5)); // 120
console.log(isPrime(17)); // true
console.log(lcm(4, 6)); // 12
console.log(gcd(8, 12)); // 4📘 API Reference
| Function | Description | Example |
| -------------------- | ---------------------------------------------- | ------------------------------------------- |
| lcm(a, b) | Returns LCM of two numbers | lcm(4, 6) → 12 |
| digitSum(n) | Sum of digits of the number | digitSum(1234) → 10 |
| factorial(n) | Returns factorial of n | factorial(5) → 120 |
| gcd(a, b) | Returns GCD of two numbers | gcd(8, 12) → 4 |
| gcdArray(arr) | GCD of an array of numbers | gcdArray([8, 12, 16]) → 4 |
| isPrime(n) | Checks if a number is prime | isPrime(17) → true |
| lcmArray(arr) | LCM of an array of numbers | lcmArray([4, 6, 8]) → 24 |
| allFactors(n) | Returns all factors of a number | allFactors(12) → [1, 2, 3, 4, 6, 12] |
| primeFactors(n) | Returns prime factors of a number | primeFactors(12) → [2, 2, 3] |
| primeNumbers(a, b) | Returns all prime numbers in the range [a, b] | primeNumbers(10, 20) → [11, 13, 17, 19] |
🧪 Running Tests
npm test🤝 Contributing
Feel free to open an issue or submit a pull request. Contributions are welcome!
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
🔗 Links
NPM Package: math-utils-fast GitHub Repository: github.com/shivanijadoun/math-utils-fast
