simple-math-toolkit
v1.0.1
Published
A simple math utility package with common mathematical operations
Maintainers
Readme
simple-math-toolkit
A simple math utility package with common mathematical operations.
Installation
npm install simple-math-toolkitUsage
const math = require('simple-math-toolkit');
// Basic arithmetic
math.add(1, 2, 3); // 6
math.subtract(10, 3, 2); // 5
math.multiply(2, 3, 4); // 24
math.divide(100, 2, 5); // 10
// Power & root
math.power(2, 10); // 1024
math.sqrt(16); // 4
// Advanced
math.factorial(5); // 120
math.isPrime(17); // true
math.mean(1, 2, 3, 4, 5); // 3API
add(...nums)
Returns the sum of all arguments.
subtract(...nums)
Subtracts all subsequent arguments from the first.
multiply(...nums)
Returns the product of all arguments.
divide(...nums)
Divides the first argument by all subsequent arguments. Throws on division by zero.
power(base, exponent)
Returns base raised to exponent.
sqrt(n)
Returns the square root of n. Throws on negative input.
factorial(n)
Returns the factorial of n. Throws on negative input.
isPrime(n)
Returns true if n is a prime number.
mean(...nums)
Returns the arithmetic mean of all arguments.
License
MIT
