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) *Int

Parameters & Attributes

NameTypeDescription
nint64Population size.
kint64Number 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))}
Go Reference