Browse Source

上传文件至 ''

管理员 7 years ago
parent
commit
3699f45df7
1 changed files with 21 additions and 0 deletions
  1. 21 0
      birthday.py

+ 21 - 0
birthday.py

@@ -0,0 +1,21 @@
+#coding=utf-8
+'''
+Created on 2017年6月9日
+@vsersion:python3.6
+@author: liuyuqi
+'''
+from scipy.special import comb, perm
+from math import factorial
+#1-C(365,n)n!/(365)^n
+init=365;
+k=0;
+for n in range(4,init):
+    pk=1-comb(365,n)*factorial(n)/pow(365,n);
+    if pk>=0.5 :
+        k=n;
+        break;
+print(k)
+# perm(m, n) 排列数
+# comb(3, 2) 组合数
+# pow(a,b) n次方
+# factorial (x)阶乘