aboutsummaryrefslogtreecommitdiff
path: root/python/cumples.py
blob: 47f37ad7d7eaa322c033c23cf9b199a1d6ddf32f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/python

"""
Calculates chance of two or more people sharing their birthday for a group of 0-100
people. Assumes flat distribution of birthdays throughout the year.
"""

def chance(n):
    x = 1.
    substract = 1.
    for i in range(n):
        substract *= ((1461-i*4)/1461.)
    return x - substract

for i in range(100):
    print ("%d %f" % (i, chance(i)))