func LnChoose(n int64, i int64) float64 {
nn:= float64(n)
ii:= float64(i)
	smaller := ii
	if nn-ii < smaller {
		smaller = nn - ii
	}
	return LnPartialFact(nn, smaller) - LnFact(smaller)
}
LnChoose returns the natural logarithm of the binomial coefficient for integer n  and k.
package fn
import (
	"math"
)
func lfastchoose(n, k float64) float64 {
	return -log(n+1) - LnB(n-k+1, k+1)
}
func lfastchoose2(n, k float64) (float64, int) {
	r, s_choose := math.Lgamma(n - k + 1)
	p, _ := math.Lgamma(n + 1)
	q, _ := math.Lgamma(k + 1)
	return p - q - r, s_choose
}
func FChoose(n, k float64) float64 {
	const k_small_max = 30.0
	k0 := k
	k = floor(k + 0.5)
	if isNaN(n) || isNaN(k) {
		return n + k
	}
	if abs(k-k0) > 1e-7 {
		panic("k must be integer valued float64")
	}
	if k < k_small_max {
		if n-k < k && n >= 0 && isInt(n) {  
			k = n - k
		}
		if k < 0 {
			return 0
		}
		if k == 0 {
			return 1
		}
		r := n
		for j := 2.0; j <= k; j++ {
			r *= (n - j + 1) / j
		}
		if isInt(n) {
			return floor(r + 0.5)
		} else {
			return floor(r)
		}
	}
	if n < 0 {
		r := FChoose(-n+k-1, k)
		if isOdd(k) {
			r = -r
		}
		return r
	} else if isInt(n) {
		n = floor(n + 0.5)
		if n < k {
			return 0
		}
		if n-k < k_small_max {  
			return FChoose(n, n-k)
		}
		return floor(exp(lfastchoose(n, k)) + 0.5)
	}
	if n < k-1 {
		r, s_choose := lfastchoose2(n, k)
		return float64(s_choose) * exp(r)
	}
	return exp(lfastchoose(n, k))
}
func LnFChoose(n, k float64) float64 {
	k0 := k
	k = floor(k + 0.5)
	if isNaN(n) || isNaN(k) {
		return n + k
	}
	if abs(k-k0) > 1e-7 {
		panic("k must be integer valued float64")
	}
	if k < 2 {
		if k < 0 {
			return negInf
		}
		if k == 0 {
			return 0
		}
		return log(abs(n))
	}
	if n < 0 {
		return LnFChoose(-n+k-1, k)
	} else if isInt(n) {
		n = floor(n + 0.5)
		if n < k {
			return negInf
		}
		if n-k < 2 {
			return LnFChoose(n, n-k)  
		}
		return lfastchoose(n, k)
	}
	if n < k-1 {
		r, _ := lfastchoose2(n, k)
		return r
	}
	return lfastchoose(n, k)
}
func Choose(n int64, i int64) int64 {
	smaller := i
	if n-i < smaller {
		smaller = n - i
	}
	return PartialFactInt(n, smaller) / FactInt(smaller)
}