aboutsummaryrefslogtreecommitdiff
path: root/src/math
diff options
context:
space:
mode:
authorEric Lagergren <eric@ericlagergren.com>2022-11-03 23:13:37 -0700
committerGopher Robot <gobot@golang.org>2022-11-08 05:24:43 +0000
commit9860faa5127931183e4dfb716d89ce7dface3f41 (patch)
tree41d397e816c100ae10a2cb99777bda53253830f1 /src/math
parente6f662d7b071c659f4146408e31671cb32e2104c (diff)
downloadgo-9860faa5127931183e4dfb716d89ce7dface3f41.tar.xz
math/big: remove underscores from Binomial docs
Change-Id: I7605bcbbaa64bb4273ad458a157b1c6011467973 Reviewed-on: https://go-review.googlesource.com/c/go/+/447915 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/math')
-rw-r--r--src/math/big/int.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/math/big/int.go b/src/math/big/int.go
index 411a56966b..29b5ddf3a5 100644
--- a/src/math/big/int.go
+++ b/src/math/big/int.go
@@ -206,13 +206,13 @@ func (z *Int) MulRange(a, b int64) *Int {
}
// Binomial sets z to the binomial coefficient C(n, k) and returns z.
-func (z *Int) Binomial(n_, k_ int64) *Int {
- if k_ > n_ {
+func (z *Int) Binomial(n, k int64) *Int {
+ if k > n {
return z.SetInt64(0)
}
// reduce the number of multiplications by reducing k
- if k_ > n_-k_ {
- k_ = n_ - k_ // C(n, k) == C(n, n-k)
+ if k > n-k {
+ k = n - k // C(n, k) == C(n, n-k)
}
// C(n, k) == n * (n-1) * ... * (n-k+1) / k * (k-1) * ... * 1
// == n * (n-1) * ... * (n-k+1) / 1 * (1+1) * ... * k
@@ -235,12 +235,12 @@ func (z *Int) Binomial(n_, k_ int64) *Int {
// i++
// z /= i
// }
- var n, k, i, t Int
- n.SetInt64(n_)
- k.SetInt64(k_)
+ var N, K, i, t Int
+ N.SetInt64(n)
+ K.SetInt64(k)
z.Set(intOne)
- for i.Cmp(&k) < 0 {
- z.Mul(z, t.Sub(&n, &i))
+ for i.Cmp(&K) < 0 {
+ z.Mul(z, t.Sub(&N, &i))
i.Add(&i, intOne)
z.Quo(z, &i)
}