# Mathematical operations

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

<table data-full-width="true"><thead><tr><th>Function</th><th>Description</th><th data-type="content-ref">Source</th></tr></thead><tbody><tr><td><code>int factorial(int n)</code></td><td>Find the factorial of n</td><td><a href="/pages/vnPUjbDcXixKFpH9oQE8">/pages/vnPUjbDcXixKFpH9oQE8</a></td></tr><tr><td><code>long long factorialL(int n)</code></td><td>Find the factorial of n</td><td><a href="/pages/qvCVfEkP93pSbYCWwgeE">/pages/qvCVfEkP93pSbYCWwgeE</a></td></tr><tr><td><code>std::vector&#x3C;int> pascal(int n)</code></td><td>Return the nth row of pascal triangle</td><td><a href="/pages/6bMoOeZiKTFcYXjXItWy">/pages/6bMoOeZiKTFcYXjXItWy</a></td></tr><tr><td><code>int combinations(int n, int k)</code></td><td>How many unique combinations are there with a population of n, whilst selecting k items. </td><td><a href="/pages/JuYT2w2FRvroa4sYprHy">/pages/JuYT2w2FRvroa4sYprHy</a></td></tr><tr><td><code>int combinationsWithRep(int n, int k)</code></td><td>How many combinations are there with a population of n, whilst selecting k items (items have repetition). </td><td><a href="/pages/OcsdnaEF3wTlBvMhjeIE">/pages/OcsdnaEF3wTlBvMhjeIE</a></td></tr><tr><td><code>int permutations(int n, int k)</code></td><td>Permutate k items in population size n. </td><td><a href="/pages/J4FR8QApkJN4ugqDR7yq">/pages/J4FR8QApkJN4ugqDR7yq</a></td></tr><tr><td><code>int pow(int a, int n)</code></td><td>Raise a to the power of n</td><td><a href="/pages/Bf6MPvG0uf92W9x98r7k">/pages/Bf6MPvG0uf92W9x98r7k</a></td></tr><tr><td><code>double pow(double a, int n)</code></td><td>Raise a to the power of n</td><td><a href="/pages/Bf6MPvG0uf92W9x98r7k">/pages/Bf6MPvG0uf92W9x98r7k</a></td></tr><tr><td><code>double pow(int a, double n)</code></td><td>Raise a to the power of n</td><td><a href="/pages/Bf6MPvG0uf92W9x98r7k">/pages/Bf6MPvG0uf92W9x98r7k</a></td></tr><tr><td><code>double pow(double a, double n)</code></td><td>Raise a to the power of n</td><td><a href="/pages/Bf6MPvG0uf92W9x98r7k">/pages/Bf6MPvG0uf92W9x98r7k</a></td></tr><tr><td><code>int GCD(int a, int b)</code></td><td>Find GCD of two numbers</td><td><a href="/pages/1e2dopEoUxuWKtcrw8kX">/pages/1e2dopEoUxuWKtcrw8kX</a></td></tr><tr><td><code>int LCM(int a, int b)</code></td><td>Find LCM of two numbers</td><td><a href="/pages/JI1GpoRZF75fvxhbYMpQ">/pages/JI1GpoRZF75fvxhbYMpQ</a></td></tr><tr><td><code>add&#x3C;return_type>(a, b)</code></td><td>Add two numbers</td><td><a href="/pages/LrUg5guY6pnS2D38i7Ll">/pages/LrUg5guY6pnS2D38i7Ll</a></td></tr><tr><td><code>subtract&#x3C;return_type>(a, b)</code></td><td>Subtract two numbers</td><td><a href="/pages/icARg9XsxCepwDtX95IZ">/pages/icARg9XsxCepwDtX95IZ</a></td></tr><tr><td><code>multiply&#x3C;return_type>(a, b)</code></td><td>Multiply two numbers</td><td><a href="/pages/oMnWhrKxvVAbXCQfGRr3">/pages/oMnWhrKxvVAbXCQfGRr3</a></td></tr><tr><td><code>divide&#x3C;return_type>(a, b)</code></td><td>Divide two numbers</td><td><a href="/pages/Cuk3GyxxypqXss2USbeh">/pages/Cuk3GyxxypqXss2USbeh</a></td></tr><tr><td><code>sin(x)</code></td><td>Compute sine</td><td><a href="/pages/TDxrsMj5BRcqF6fJlsQD">/pages/TDxrsMj5BRcqF6fJlsQD</a></td></tr><tr><td><code>cos(x)</code></td><td>Compute cosine</td><td><a href="/pages/sTmQJLUYQcKYfa2mgjem">/pages/sTmQJLUYQcKYfa2mgjem</a></td></tr><tr><td><code>ln&#x3C;return_type>(x)</code></td><td>Find the natural logarithm of a number</td><td><a href="/pages/SZjB8OoJBK6KBtPiCRNW">/pages/SZjB8OoJBK6KBtPiCRNW</a></td></tr><tr><td><code>log&#x3C;return_type>(base, argument)</code></td><td>Find the logarithm of argument with a given base</td><td><a href="/pages/x8cqky3FdoXICHAQ9cRN">/pages/x8cqky3FdoXICHAQ9cRN</a></td></tr><tr><td><code>radToDeg&#x3C;return_type>(rad)</code></td><td>Convert radians to degrees</td><td><a href="/pages/3cAVP5uBtYDHiUrCPIcf">/pages/3cAVP5uBtYDHiUrCPIcf</a></td></tr><tr><td><code>degToRad&#x3C;return_type>(deg)</code></td><td>Convert degrees to radians</td><td><a href="/pages/rfb5HDITUM9avw6zHa8R">/pages/rfb5HDITUM9avw6zHa8R</a></td></tr><tr><td><code>mod&#x3C;return_type>(dividend, divisor)</code></td><td>Remainder of a quotient</td><td><a href="/pages/moTJ22MajpxHXZJDiff8">/pages/moTJ22MajpxHXZJDiff8</a></td></tr><tr><td><code>abs&#x3C;return_type>(val)</code></td><td>Absolute value of number</td><td><a href="/pages/4Do0Utn5aU0H6X7XhPs4">/pages/4Do0Utn5aU0H6X7XhPs4</a></td></tr><tr><td><code>int floor(x)</code></td><td>Round value down</td><td><a href="/pages/oZFMDNy9HcN7x4G902dR">/pages/oZFMDNy9HcN7x4G902dR</a></td></tr><tr><td><code>int ceil(x)</code></td><td>Round value up</td><td><a href="/pages/kKv5vqTBOdaGB25r0uPX">/pages/kKv5vqTBOdaGB25r0uPX</a></td></tr><tr><td><code>root&#x3C;return_type>(n, a)</code></td><td>Find the nth root of a number</td><td><a href="/pages/ZP5JI93a6AVBUZOeDWzd">/pages/ZP5JI93a6AVBUZOeDWzd</a></td></tr><tr><td><code>exp&#x3C;return_type>(x)</code></td><td>Exponential function</td><td><a href="/pages/ClnNrHzCcXObOenskBW0">/pages/ClnNrHzCcXObOenskBW0</a></td></tr><tr><td><code>tan(x)</code></td><td>Compute tangent</td><td><a href="/pages/otGDd0womqgJTm9flpIe">/pages/otGDd0womqgJTm9flpIe</a></td></tr><tr><td><code>arcsin(x)</code></td><td>Compute arcsine</td><td><a href="/pages/wzybz9JV3c1m3kAHXwzK">/pages/wzybz9JV3c1m3kAHXwzK</a></td></tr><tr><td><code>arccos(x)</code></td><td>Compute arccosine</td><td><a href="/pages/Uie2If9WgSW3ax86P1XE">/pages/Uie2If9WgSW3ax86P1XE</a></td></tr><tr><td><code>arctan(x)</code></td><td>Compute arctangent</td><td><a href="/pages/ZlsWu2DBn19ytvGfu8Q9">/pages/ZlsWu2DBn19ytvGfu8Q9</a></td></tr><tr><td><code>sinh(x)</code></td><td>Compute hyberbolic sine</td><td><a href="/pages/VA3CVS0UEIT9YyMWyazY">/pages/VA3CVS0UEIT9YyMWyazY</a></td></tr><tr><td><code>cosh(x)</code></td><td>Compute hyperbolic cosine</td><td><a href="/pages/3bceTGNBQSQrkGXmj1fK">/pages/3bceTGNBQSQrkGXmj1fK</a></td></tr><tr><td><code>int round(x)</code></td><td>Rounds a number up/down</td><td><a href="/pages/jwVEo7RhTjESAxqYXkla">/pages/jwVEo7RhTjESAxqYXkla</a></td></tr></tbody></table>

{% hint style="info" %}
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.&#x20;
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://math-5.gitbook.io/math/reference/mathematical-operations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
