瀏覽代碼

Lattice paths

Adel Qalieh 13 年之前
父節點
當前提交
a98563fbdb
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      15.py

+ 8 - 0
15.py

@@ -0,0 +1,8 @@
+from math import factorial
+
+# Combinations
+def combin(n, r):
+	return factorial(n) / (factorial(r) * factorial(n-r))
+
+# Number of paths in a m x n lattice given by combin(m+n, m)
+print combin(20 + 20, 20)