Skip to content

Commit bccc793

Browse files
committed
docs: Add Documentation for Combinatorics and Permutations in C++
1 parent 9c87874 commit bccc793

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Diff for: website/docs/math/combinatorics.md

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ int64_t fastpow(int64_t a, int64_t b) {
2727
```
2828
Efficiently computes $a^b \mod \text{md}$ using recursive exponentiation by squaring. This function operates in $O(\log b)$ time, making it suitable for handling large exponents.
2929
30+
#### `inverse`
31+
```cpp
32+
auto inverse = [&](int64_t num) -> int64_t {
33+
return fastpow(num, md - 2);
34+
};
35+
```
36+
Computes the modular inverse of a number $\( \text{num} \mod \text{md} \)$ using Fermat's Little Theorem. This method is efficient and operates in $\( O(\log \text{md}) \)$.
37+
3038
### 3. Precomputations
3139
#### Factorial Table Construction
3240
```cpp
@@ -42,6 +50,7 @@ void buildFactorial() {
4250
```
4351
Precomputes factorial values up to a maximum limit (`MXN`) modulo `md`. This precomputation allows for constant-time access to factorial values, which are used extensively in combinatorics calculations.
4452

53+
4554
### 4. Combinatorics
4655

4756
#### Binomial Coefficients (`nCk`)

0 commit comments

Comments
 (0)