math-ezy
v1.0.2
Published
An npm package to mathematical computations
Downloads
34
Maintainers
Readme
math-ezy
A lightweight and efficient math utilities package providing a collection of essential math functions such as prime checks, factorials, trigonometric calculations, and more.
Installation
You can install this package using npm:
npm install math-ezy
Documentation
Once installed, you can import the functions you need
import { add, subtract, factorial, isPrime, fibonacci } from 'math-ezy';
// Example usage
console.log(add(1, 2, 3)); // Output: 6
console.log(factorial(5)); // Output: 120
Functions
isPrime(num)
isPrime(7) // output : true
factorial(num)
factorial(5) // output : 120
gcd(num1, num2)
gcd(12, 15) // output : 3
fibonacci(n) Returns the nth fibonacci number
fibonacci(5) // output : 5
geometricSeriesSum(a, r, n)
geometricSeriesSum(1, 2, 5) // output : 31
arithmeticSeriesSum(a, d, n)
arithmeticSeriesSum(1, 2, 5) // output : 25
distance([x1, y1], [x2, y2])
distance([0, 0], [3, 4]); // 5
combinations(n, r)
combinations(5, 3); // 10
permutations(n, r)
permutations(5, 3); // 60
log(base, value)
log(2, 8); // 3
solveQuadratic(a, b, c)
solveQuadratic(1, -3, 2); // [2, 1]
solveLinear(a, b)
solveLinear(4, -16); // 4
sin(degrees)
sin(30); // 0.5
cos(degrees)
cos(60); // 0.5
tan(degrees)
tan(45); // 1
add(...numbers)
add(1, 2, 3, 4); // 10
subtract(...numbers)
subtract(10, 2, 1); // 7
multiply(...numbers)
multiply(2, 3, 4); // 24
divide(a, b)
divide(10, 2); // 5
Contributing
Please feel free to contribute on this package to make it the best.
Licence
Licensed under the ISC license.