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; }
1
Probability at least two people have the same birthday is 0.891232