]> Cypherpunks repositories - gostls13.git/commitdiff
math/big: remove underscores from Binomial docs
authorEric Lagergren <eric@ericlagergren.com>
Fri, 4 Nov 2022 06:13:37 +0000 (23:13 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 8 Nov 2022 05:24:43 +0000 (05:24 +0000)
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>

src/math/big/int.go

index 411a56966b9f0634d7cad04aed0171a3bc93d25c..29b5ddf3a5e528432f2adb424f834dfcb58839ae 100644 (file)
@@ -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)
        }