Standard library / math/big
big.Int.Binomial()
Calculate the binomial coefficient n choose k. Use nonnegative n and 0 <= k <= n for ordinary combinations. This method writes to the receiver (use a separate destination to preserve inputs when needed). Expected stdout: '120\n'.
Formal Syntax & Structure
go syntaxgo
func (z *Int) Binomial(n, k int64) *IntParameters & Attributes
| Name | Type | Description |
|---|---|---|
| n | int64 | Population size. |
| k | int64 | Number selected. |
Return Value
*Int
Returns the result described above; see the example for the observed behavior.
Working Example
Example Snippetgo
package main
import ( "fmt" "math/big")
func main() { fmt.Println(new(big.Int).Binomial(10, 3))}