aboutsummaryrefslogtreecommitdiff
path: root/python/cumples.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/cumples.py')
-rwxr-xr-xpython/cumples.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/python/cumples.py b/python/cumples.py
new file mode 100755
index 0000000..47f37ad
--- /dev/null
+++ b/python/cumples.py
@@ -0,0 +1,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)))