birthday.R 198 B

12345678910111213141516
  1. #1-C(365,n)n!/(365)^n
  2. init=365
  3. k=0
  4. for(n in 4:init){
  5. pk=1-choose(365,n)*factorial(n)/365^n
  6. if(pk>=0.5){
  7. k=n;
  8. break;
  9. }
  10. }
  11. print(k)
  12. choose(n,k)
  13. factorial(5)
  14. choose(4,2) #组合
  15. #sqrt(x)