main.m 219 B

123456789101112
  1. %1-C(365,n)n!/(365)^n
  2. init=365;
  3. k=0;
  4. for n=4:init
  5. pk=1-nchoosek(365,n)*factorial(n)/power(365,n);
  6. %pk=1-factorial(364)/(power(365,n)*factorial(n-2));
  7. if pk>=0.5
  8. k=n;
  9. break;
  10. end
  11. end
  12. k