TShopping
標題:
Python math.comb() 如何算出來
[打印本頁]
作者:
woff
時間:
2021-1-7 15:02
標題:
Python math.comb() 如何算出來
就是高中數學的那個排列組合的組合,C。從 n 樣東西里,取出 m 樣,計算有幾種取法
就是那個組合的 nCm
公式寫出來就是 n!/( (n-m)!*m! )
wiki 介紹
# Import math Library
import math
# Initialize the number of items to choose from
n = 7
# Initialize the number of possibilities to choose
k = 5
# Print total number of possible combinations
print (math.comb(n, k))
複製代碼
The result will be:
21
歡迎光臨 TShopping (http://www.tshopping.com.tw/)
Powered by Discuz! X3.2