@hero-page/hero-math-functions

1.0.0 • Public • Published

This entire repository was created completely with AI, using the hero-ai-package-creator, which is open-source, uses GPT-4, and is written & maintained by Sam Chahine ❣️🧞‍♀️

hero-math-functions

A set of mathematical functions for performing basic arithmetic operations, finding the min/max value in an array, and calculating mean, median, and mode.

Functions

add

Adds two numbers together.

Test cases: add(2, 3) returns 5.

Extreme cases to handle: very large numbers, very small numbers.

Ignore non-numeric inputs.

subtract

Subtracts one number from another.

Test cases: subtract(7, 4) returns 3.

Extreme cases to handle: negative results and very large/small numbers.

Ignore non-numeric inputs.

multiply

Multiplies two numbers together.

Test cases: multiply(3, 5) returns 15.

Extreme cases to handle: very large/small numbers and products.

Ignore non-numeric inputs.

divide

Divides one number by another.

Test cases: divide(10, 2) returns 5.

Extreme cases to handle: dividing by zero and very large/small numbers.

Ignore non-numeric inputs.

min

Returns the minimum value in an array.

Test cases: min([1, 2, 3]) returns 1.

Extreme cases to handle: very large arrays and empty arrays.

Ignore non-numeric values.

max

Returns the maximum value in an array.

Test cases: max([1, 2, 3]) returns 3.

Extreme cases to handle: very large arrays and empty arrays.

Ignore non-numeric values.

mean

Calculates the mean (average) of an array of numbers.

Test cases: mean([1, 2, 3]) returns 2.

Extreme cases to handle: very large arrays, empty arrays, and arrays with non-numeric values.

Ignore non-numeric values.

median

Calculates the median (middle) value of an array of numbers.

Test cases: median([1, 2, 3]) returns 2.

Extreme cases to handle: very large arrays, empty arrays, and arrays with non-numeric values.

Ignore non-numeric values.

mode

Calculates the mode (most frequent) value in an array of numbers.

Test cases: mode([1, 2, 2, 3]) returns 2.

Extreme cases to handle: very large arrays, empty arrays, and arrays with non-numeric values.

Ignore non-numeric values.

abs

Returns the absolute value of a number.

Test cases: abs(-5) returns 5.

Extreme cases to handle: very large/small numbers.

Ignore non-numeric inputs.

square

Squares a number.

Test cases: square(4) returns 16.

Extreme cases to handle: very large/small numbers.

Ignore non-numeric inputs.

squareRoot

Returns the square root of a number.

Test cases: squareRoot(9) returns 3.

Extreme cases to handle: negative inputs and very large/small numbers.

Ignore non-numeric inputs.

power

Raises a number to the given exponent.

Test cases: power(2, 3) returns 8.

Extreme cases to handle: very large/small numbers and exponents.

Ignore non-numeric inputs.

round

Rounds a number to the nearest integer.

Test cases: round(3.5) returns 4.

Extreme cases to handle: very large/small numbers.

Ignore non-numeric inputs.

ceil

Rounds a number up to the nearest integer.

Test cases: ceil(3.2) returns 4.

Extreme cases to handle: very large/small numbers.

Ignore non-numeric inputs.

floor

Rounds a number down to the nearest integer.

Test cases: floor(3.7) returns 3.

Extreme cases to handle: very large/small numbers.

Ignore non-numeric inputs.

trunc

Truncates (removes the decimal) a number.

Test cases: trunc(3.7) returns 3.

Extreme cases to handle: very large/small numbers.

Ignore non-numeric inputs.

gcd

Finds the greatest common divisor (GCD) of two numbers.

Test cases: gcd(5, 10) returns 5.

Extreme cases to handle: very large/small numbers and negative inputs.

Ignore non-numeric inputs.

lcm

Finds the least common multiple (LCM) of two numbers.

Test cases: lcm(3, 5) returns 15.

Extreme cases to handle: very large/small numbers and negative inputs.

Ignore non-numeric inputs.

isPrime

Determines if a number is prime.

Test cases: isPrime(5) returns true.

Extreme cases to handle: very large/small numbers and non-integer inputs.

Ignore non-numeric inputs.

Sam Chahine, at Hero

Tests for abs

abs

Tests for floor

floor

Tests for gcd

gcd

Tests for ceil

ceil

Tests for lcm

lcm

Tests for max

max

Tests for mean

mean

Tests for median

median

Tests for isPrime

isPrime

Tests for mode

mode

Tests for multiply

multiply

Tests for power

power

Tests for round

round

Tests for min

min

Tests for squareRoot

squareRoot

Tests for subtract

subtract

Tests for trunc

trunc

Tests for square

square

Tests for add

add

Tests for divide

divide

Package Sidebar

Install

npm i @hero-page/hero-math-functions

Weekly Downloads

6

Version

1.0.0

License

MIT

Unpacked Size

63.7 kB

Total Files

44

Last publish

Collaborators

  • hero-page