Skip to content

Instantly share code, notes, and snippets.

@efruchter
Created November 17, 2021 01:18
Show Gist options
  • Save efruchter/8aef9abbee97090ca7148834538c54fb to your computer and use it in GitHub Desktop.
Save efruchter/8aef9abbee97090ca7148834538c54fb to your computer and use it in GitHub Desktop.
calculate the probabilities that a group of n people will have at least two people within that share the same birthday.
double CurProb = 1;
std::cout << 1 << ": " << 0.0 << std::endl;
for (int i = 1; i < 100; i++)
{
double bp = (365.0 - (double)i) / 365.0;
CurProb *= bp;
std::cout << (i + 1) << ": " << (1.0 - CurProb) << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment