npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mathrizz

v3.0.0

Published

Library with multiple mathematical functions/methods

Downloads

10

Readme

MathRizz Library

MathRizz is a JavaScript library that provides multiple mathematical functions and methods. It includes basic arithmetic operations, power and square root calculations, rounding functions, minimum and maximum value calculations, summation, factorial, greatest common divisor (GCD) and least common multiple (LCM), prime number detection, trigonometric functions, logarithms, exponential function, random number generation, number conversion, and various other mathematical utilities.

Installation

Install the MathRizz library using npm:

npm install mathrizz

How to use it

Import the MathRizz library in your JavaScript code:

const MathRizz = require('mathrizz');

or

import MathRizz from 'mathrizz';

Functions

The library provides the following mathematical functions/methods:

Basic Operations:

  • add(a, b): Returns the sum of two numbers.
  • subtract(a, b): Returns the difference between two numbers.
  • multiply(a, b): Returns the product of two numbers.
  • divide(a, b): Returns the quotient of two numbers.
  • power(n, e): Returns the result of raising a number to a given exponent.

Square Root and Absolute Value:

  • sqrt(n): Returns the square root of a number. If the number is negative, returns NaN.
  • abs(n): Returns the absolute value of a number.

Rounding:

  • roundUp(n): Returns the smallest integer greater than or equal to a number.
  • roundDown(n): Returns the largest integer less than or equal to a number.
  • round(n): Returns the nearest integer to a number. If the decimal part is exactly 0.5, rounds up.

Minimum and Maximum:

  • min(n): Returns the smallest number from an array of numbers.
  • max(n): Returns the largest number from an array of numbers.

Sum and Factorial:

  • sum(n): Returns the sum of all numbers in an array.
  • fact(n): Returns the factorial of a non-negative integer.

Greatest Common Divisor and Least Common Multiple:

  • gcd(n): Returns the greatest common divisor (GCD) of multiple numbers.
  • lcm(n): Returns the least common multiple (LCM) of multiple numbers.

Primality and Parity:

  • isPrime(n): Checks if a number is prime.
  • isEven(n): Checks if a number is even.
  • isOdd(n): Checks if a number is odd.

Trigonometric Functions:

  • toRadians(d): Converts an angle from degrees to radians.
  • toDegrees(r): Converts an angle from radians to degrees.
  • sin(a): Returns the sine of an angle.
  • cos(a): Returns the cosine of an angle.
  • tan(a): Returns the tangent of an angle.
  • cot(a): Returns the cotangent of an angle.
  • sec(a): Returns the secant of an angle.
  • csc(a): Returns the cosecant of an angle.

Logarithmic and Exponential Functions:

  • log(n): Returns the natural logarithm (base e) of a number.
  • log10(n): Returns the logarithm (base 10) of a number.
  • exp(n): Returns the exponential function of a number.

Random Numbers:

  • rand(): Returns a random floating-point number between 0 and 1.
  • randInt(n, m): Returns a random integer between n and m (inclusive).

Number Conversion:

toBin(n): Converts a number to its binary representation. toOct(n): Converts a number to its octal representation. toHex(n): Converts a number to its hexadecimal representation.

Miscellaneous:

  • isPalindrome(n): Checks if a number is a palindrome.
  • isPerfectSquare(n): Checks if a number is a perfect square.

Amicable Numbers:

  • isAmicable(n, m): Returns true if n and m are amicable numbers; otherwise, returns false.

Prime Factors:

  • primeFactors(n): Returns an array containing the prime factors of n.

Armstrong Number:

  • isArmstrong(n): Returns true if n is an Armstrong number; otherwise, returns false.

Fibonacci Sequence:

  • fibonacci(n): Returns the nth number in the Fibonacci sequence.

Statistical Functions:

  • mean(n): Returns the mean (average) of the numbers in the array n.
  • median(n): Returns the median of the numbers in the array n.
  • mode(n): Returns an array containing the mode(s) of the numbers in the array n.
  • range(n): Returns the range of the numbers in the array n.
  • standardDeviation(n): Returns the standard deviation of the numbers in the array n.

Combinatorial Functions:

  • binomialCoefficient(n, k): Returns the binomial coefficient "n choose k".
  • permutations(n, k): Returns the number of permutations of n objects taken k at a time.
  • combinations(n, k): Returns the number of combinations of n objects taken k at a time.

Geometry

  • calcCircleArea(r): Returns the area of a circle given the ray.
  • calcCircumference(r): Returns the circumference of a circle given the ray.
  • calcSquareArea(l): Returns the area of a square given the side.
  • calcSquarePerim(l): Returns the perimeter of a square given the side.
  • calcRectArea(b, h): Returns the area of a rectangle given the base and the height.
  • calcRectPerim(b, h): Returns the perimeter of a rectangle given the base and the height.
  • calcTrapezeArea(B, b, h): Returns the area of a trapeze given the two bases and the height.
  • calcTrapezePerim(B, b, l): Returns the perimeter of a trapeze given the two bases and the oblique side.
  • calcTriangleArea(b, h): Returns the area of a triangle given the base and the height.
  • calcTrianglePerim(c1, c2, h): Returns the perimeter of a triangle given the two cathetuses and the hypotenuse.
  • calcTriangleCat(c, h): Returns the cathetus of a triangle given the other cathetus and the hypotenuse.
  • calcTriangleHyp(c1, c2): Returns the hypotenuse of a triangle given the two cathetuses.

Contributing:

If you wish to contribute to the creation of this library, feel free to do so by opening an issue on the connected GitHub page