TShopping

 找回密碼
 註冊
搜索
查看: 671|回復: 0
打印 上一主題 下一主題

[教學] Python math.comb() 如何算出來

[複製鏈接]
跳轉到指定樓層
1#
發表於 2021-1-7 15:02:41 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
 
Push to Facebook
就是高中數學的那個排列組合的組合,C。從 n 樣東西里,取出 m 樣,計算有幾種取法
就是那個組合的 nCm
公式寫出來就是 n!/( (n-m)!*m! )
  1. # Import math Library
  2. import math

  3. # Initialize the number of items to choose from
  4. n = 7

  5. # Initialize the number of possibilities to choose
  6. k = 5

  7. # Print total number of possible combinations
  8. print (math.comb(n, k))
複製代碼
The result will be:

21


 

臉書網友討論
*滑块验证:
您需要登錄後才可以回帖 登錄 | 註冊 |

本版積分規則



Archiver|手機版|小黑屋|免責聲明|TShopping

GMT+8, 2024-4-26 18:42 , Processed in 0.046039 second(s), 22 queries .

本論壇言論純屬發表者個人意見,與 TShopping綜合論壇 立場無關 如有意見侵犯了您的權益 請寫信聯絡我們。

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表