@satyakiraj/quicksolve
v1.0.2
Published
A simple and lightweight JavaScript library for performing mathematical operations such as addition, subtraction, multiplication, division, and more.
Readme
Math Utilities Library
A simple and lightweight JavaScript library for performing mathematical operations such as addition, subtraction, multiplication, division, and more.
Features
- Add, subtract, multiply, or divide numbers
- Compute advanced operations like factorials, GCD, LCM, square roots, and more
- Generate random integers within a range
- Calculate averages, medians, and powers
Installation
Install via npm:
npm install @satyakiraj/quicksolveAlternatively, you can include the library in your project using a CDN:
<script src="https://cdn.jsdelivr.net/npm/@satyakiraj/quicksolve"></script>Usage
Import the Library
In Node.js:
const math = require('@satyakiraj/quicksolve');In ES Modules:
import * as math from '@satyakiraj/quicksolve';Examples
Basic Arithmetic
// Addition
console.log(math.add(1, 2, 3)); // Output: 6
// Subtraction
console.log(math.subtract(10, 5)); // Output: 5
// Multiplication
console.log(math.multiply(2, 3, 4)); // Output: 24
// Division
console.log(math.divide(10, 3)); // Output: 3.33333Advanced Operations
// Square Root
console.log(math.sqrt(16)); // Output: 4.00000
// Power
console.log(math.power(2, 3)); // Output: 8
// Factorial
console.log(math.factorial(5)); // Output: 120
// GCD
console.log(math.gcd(12, 15)); // Output: 3
// LCM
console.log(math.lcm(4, 6)); // Output: 12
// Median
console.log(math.median(1, 3, 2, 5, 4)); // Output: 3Utilities
// Generate a Random Integer
console.log(math.random(1, 100)); // Output: Random integer between 1 and 100
// Average
console.log(math.average(10, 20, 30)); // Output: 20.00000API Reference
Basic Arithmetic
add(...numbers): Returns the sum of all numbers provided.subtract(a, b): Returns the difference betweenaandb.multiply(...numbers): Returns the product of all numbers provided.divide(a, b): Returns the result of dividingabyb(up to 5 decimal places).
Advanced Functions
average(...numbers): Calculates the average of the provided numbers.factorial(n): Returns the factorial ofn.gcd(a, b): Finds the greatest common divisor of two numbers.lcm(a, b): Finds the least common multiple of two numbers.median(...numbers): Calculates the median of a set of numbers.power(base, exponent): Calculatesbaseraised to the power ofexponent.sqrt(number): Finds the square root of a number.
Utilities
random(min, max): Generates a random integer betweenminandmax(inclusive).
Author
Created by Satyaki Raj.
keywords:
- math
- calculations
- npm package
- JavaScript
