Calculates the binomial coefficient of n,k (n choose k).
Parameters |
n : Int Number of available choices.
k : Int Number of choices selected.
|
---|---|
Returns |
num : Int The number of combinations of choices, n choose k.
|
Errors |
This function does not raise any errors. |
Calculates the divisor (quotient) and modulus (remainder) amongst two integers a,b.
Parameters |
a : Int First integer.
b : Int Second integer.
|
---|---|
Returns |
arr : Array An array whose first element is the divisor (a/b) and second element is the modulus (a%b). Returns false if a or b is not an integer.
|
Errors |
This function does not raise any errors. |
Performs the extended Euclidean algorithm (calculates x,y such that ax + by = gcd(a,b) ).
Parameters |
a : Int First integer.
b : Int Second integer.
|
---|---|
Returns |
arr : Array An array whose first element is gcd(a,b), second element is x, and third element is y such that ax + by = gcd(a,b) is satisfied.
|
Errors |
This function does not raise any errors. |
Calculates the factorial of a positive integer, n.
Parameters |
n : Int A positive integer.
|
---|---|
Returns |
num : Int Factorial of n
|
Errors |
This function does not raise any errors. |
Calculates the falling factorial of a positive integer n with k steps: n!/(n-k)!
Parameters |
n : Int A positive integer.
k : Int The number of steps to fall.
|
---|---|
Returns |
r : Int Falling factorial of n with k steps. If k > n then 0 is returned.
|
Errors |
This function does not raise any errors. |
Calculates the greatest common divisor (gcd) amongst two integers.
Parameters |
a : Int First integer.
b : Int Second integer.
|
---|---|
Returns |
num : Int The gcd of a,b. If a or b are Infinity or -Infinity, then Infinity is returned. If a or b are not numbers, then NaN is returned.
|
Errors |
An error is thrown if:
|
Determines if a number is an integer.
Parameters |
n : Number A number.
|
---|---|
Returns |
bool : Boolean true if n is an integer, false otherwise.
|
Errors |
This function does not raise any errors. |
Calculates the lowest common multiple (lcm) amongst two integers.
Parameters |
a : Int First integer.
b : Int Second integer.
|
---|---|
Returns |
num : Int The lcm of a,b. If a or b are Infinity or -Infinity, then 0 is returned. If a or b are not numbers, then NaN is returned.
|
Errors |
An error is thrown if:
|
Finds the maximum value in an array.
Parameters |
arr : Array An array of numbers.
|
---|---|
Returns |
num : Int Maximum value inside arr. -Infinity is returned if arr is empty.
|
Errors |
An error is thrown if:
|
Finds the minimum value in an array.
Parameters |
arr : Array An array of numbers.
|
---|---|
Returns |
numfct : Int Minimum value inside arr. Infinity is returned if arr is empty.
|
Errors |
An error is thrown if:
|
Calculates the modular multiplicative inverse x of an integer a and modulus m, ax = 1 (mod m).
Parameters |
a : Int An integer.
m : Int Modulus.
|
---|---|
Returns |
x : Int An integer such that ax = 1 (mod m).
|
Errors |
An error is thrown if:
|
Determines if two numbers, a,b, are equal within a given margin of precision, epsilon.
Parameters |
a : Number First number.
b : Number Second number.
epsilon : Number Precision.
|
---|---|
Returns |
bool : Boolean true if they are equal within the precision, false otherwise
|
Errors |
This function does not raise any errors. |
Calculate the permutation (n choose k)
Parameters |
n : Int Number of total elements
k : Int Fixed number of elements
|
---|---|
Returns |
num : Number Number of ordered variations
|
Errors |
An error is thrown if:
|
Calculates the modulus of an exponential number, a^b mod m.
Parameters |
a : Int Base.
b : Int Exponent.
m : Int Modulus.
|
---|---|
Returns |
num : Int a^b mod m.
|
Errors |
This function does not raise any errors. |
Calculates the product of the elements of an array.
Parameters |
arr : Array An array of numbers.
|
---|---|
Returns |
num : Number The product of the elements of arr.
|
Errors |
An error is thrown if:
|
Retrieves a specified quantity, quant of elements from an array, arr at random. If allowDuplicates is true, then the resulting array is allowed to duplicates of numbers.
Parameters |
arr : Array Array of values to pick from.
quant : Int Number of values to retrieve.
allowDuplicates : Boolean Allow numbers to be returned more than once.
|
---|---|
Returns |
randomArr : Array An array of randomly chosen numbers from arr.
|
Errors |
An error is thrown if:
|
Creates a range of numbers from start (inclusive) to stop (exclusive), increasing by step each iteration. All arguments optional.
Parameters |
start : Int Start of range (included). Default value is 0.
stop : Int End of range (excluded). Default value is the value of start.
step : Int Increment size. Default value is 1.
|
---|---|
Returns |
arr : Array An array of numbers. If no arguments are given, then [0] is returned.
|
Errors |
This function does not raise any errors. |
Shuffles the elements of an array in place.
Parameters |
arr : Array An array.
|
---|---|
Returns |
shuffledArr : Number A shuffled version of arr.
|
Errors |
This function does not raise any errors. |
Calculates the square of a number.
Parameters |
n : Number A number.
|
---|---|
Returns |
num : Number n squared.
|
Errors |
This function does not raise any errors. |
Calculates the differences of elements of an array, using the first element as the starting point.
Parameters |
arr : Array An array of numbers.
|
---|---|
Returns |
num : Number The difference of the elements of arr.
|
Errors |
An error is thrown if:
|
Calculates the sum of the elements of an array.
Parameters |
arr : Array An array of numbers.
|
---|---|
Returns |
num : Number The sum of the elements of arr.
|
Errors |
An error is thrown if:
|