😱Mathematical operations

maTH library started as a library of mathematical operations made from scratch. Here's a list of all operations the library supports:

Function
Description
Source

int factorial(int n)

Find the factorial of n

long long factorialL(int n)

Find the factorial of n

std::vector<int> pascal(int n)

Return the nth row of pascal triangle

int combinations(int n, int k)

How many unique combinations are there with a population of n, whilst selecting k items.

int combinationsWithRep(int n, int k)

How many combinations are there with a population of n, whilst selecting k items (items have repetition).

int permutations(int n, int k)

Permutate k items in population size n.

int pow(int a, int n)

Raise a to the power of n

double pow(double a, int n)

Raise a to the power of n

double pow(int a, double n)

Raise a to the power of n

double pow(double a, double n)

Raise a to the power of n

int GCD(int a, int b)

Find GCD of two numbers

int LCM(int a, int b)

Find LCM of two numbers

add<return_type>(a, b)

Add two numbers

subtract<return_type>(a, b)

Subtract two numbers

multiply<return_type>(a, b)

Multiply two numbers

divide<return_type>(a, b)

Divide two numbers

sin(x)

Compute sine

cos(x)

Compute cosine

ln<return_type>(x)

Find the natural logarithm of a number

log<return_type>(base, argument)

Find the logarithm of argument with a given base

radToDeg<return_type>(rad)

Convert radians to degrees

degToRad<return_type>(deg)

Convert degrees to radians

mod<return_type>(dividend, divisor)

Remainder of a quotient

abs<return_type>(val)

Absolute value of number

int floor(x)

Round value down

int ceil(x)

Round value up

root<return_type>(n, a)

Find the nth root of a number

exp<return_type>(x)

Exponential function

tan(x)

Compute tangent

arcsin(x)

Compute arcsine

arccos(x)

Compute arccosine

arctan(x)

Compute arctangent

sinh(x)

Compute hyberbolic sine

cosh(x)

Compute hyperbolic cosine

int round(x)

Rounds a number up/down

If the argument data type is defined, eg. int round(x), it means x can be whatever data type. func_name<return_type> specifies, that you can specifically say, in which data type you want your result to be in.

Last updated