@hero-page/hero-math-functions
v1.0.0
Published
A set of mathematical functions for performing basic arithmetic operations, finding the min/max value in an array, and calculating mean, median, and mode
Downloads
1
Maintainers
Readme
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