* Extended Euclidean algorithm: returns `[g, x, y]` with `a·x + b·y = g`, * where `g = gcd(a, b)` (its sign follows `a`/`b`; callers that need a * non-negative `g` normalize the triple).
(a: bigint, b: bigint)
| 1151 | if (n === 0n && k === 0n) return 1n; |
| 1152 | if (n === 0n || k === 0n) return 0n; |
| 1153 | return S(n - 1n, k - 1n) + k * S(n - 1n, k); |
| 1154 | }; |
| 1155 | return ce.number(S(nn, mm)); |
| 1156 | }, |
| 1157 | }, |
| 1158 | |
| 1159 | StirlingS1: { |
| 1160 | description: |
| 1161 | 'Signed Stirling number of the first kind s(n, m): the coefficient of x^m in the falling factorial x(x−1)…(x−n+1). Its absolute value counts the permutations of n elements with exactly m disjoint cycles.', |
| 1162 | signature: '(integer, integer) -> integer', |
| 1163 | type: () => 'finite_integer', |
| 1164 | examples: ['StirlingS1(5, 2) // -50'], |
| 1165 | evaluate: ([n, m], { engine: ce }) => { |
| 1166 | const nn = toBigint(n); |
| 1167 | const mm = toBigint(m); |
no outgoing calls
no test coverage detected