Link Search Menu Expand Document

Combinatorics

combinatorics.ts#L19

binomial (n: number, k: number): number

Calculates the binomial coefficient nCk of two numbers n and k.

Name Type Default Description
n number    
k number    
combinatorics.ts#L8

factorial (x: number): number

Calculates the factorial of a number x.

Name Type Default Description
x number    
combinatorics.ts#L35

permutations (arr: Array<T>): Array<Array<T>>

Returns an array of all possible permutations of an input array arr. In this implementation, we always have permutations(arr)[0] == arr. From http://stackoverflow.com/questions/9960908/permutations-in-javascript

Name Type Default Description
arr Array<T>    
combinatorics.ts#L59

subsets (array: Array<T>, length: number): Array<Array<T>>

Returns an array of all possible subsets of an input array (of given length).

Name Type Default Description
array Array<T>    
length number 0  

Copyright © 2021 Mathigon.org