[ create a new paste ] login | about

Link: http://codepad.org/XWK3vHQR    [ raw code | output | fork ]

C++, pasted on Jul 19:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>

using namespace std;

int main(void)
{
  float p = 1;
  for (int i = 0; i < 40; i++)
      p *= (float) (365 - i) / (float) 365;
  
  cout << "Probability at least two people have the same birthday is " <<
  1 - p << endl;


  return 0;
}


Output:
1
Probability at least two people have the same birthday is 0.891232


Create a new paste based on this one


Comments: