Browse Source

add Rcode

liuyuqi-dellpc 7 years ago
parent
commit
c015b6cdf3
1 changed files with 16 additions and 0 deletions
  1. 16 0
      birthday.R

+ 16 - 0
birthday.R

@@ -0,0 +1,16 @@
+#1-C(365,n)n!/(365)^n
+init=365
+k=0
+for(n in 4:init){
+  pk=1-choose(365,n)*factorial(n)/365^n
+  if(pk>=0.5){
+    k=n; 
+    break;
+  }
+}
+print(k)
+
+choose(n,k)
+factorial(5)
+choose(4,2) #组合
+#sqrt(x)