CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
jackfrued

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: jackfrued/Python-100-Days
Path: blob/master/Day01-15/code/Day06/function1.py
Views: 729
1
"""
2
函数的定义和使用 - 计算组合数C(7,3)
3
4
Version: 0.1
5
Author: 骆昊
6
Date: 2018-03-05
7
"""
8
9
10
# 将求阶乘的功能封装成一个函数
11
def factorial(n):
12
result = 1
13
for num in range(1, n + 1):
14
result *= num
15
return result
16
17
18
print(factorial(7) // factorial(3) // factorial(4))
19
20