aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2020-12-13 15:00:41 +0100
committerInigoGutierrez <inigogf.95@gmail.com>2020-12-13 15:00:41 +0100
commit67a81537cd2fb38f80fbfb8d0f55a4940afb4af7 (patch)
tree71902cc38aef65659e5e88c2e86a400eda71bda6 /python
parent6b3555e44f61adc6cfe3de901b02e127bd23b146 (diff)
downloadscripts-67a81537cd2fb38f80fbfb8d0f55a4940afb4af7.tar.gz
scripts-67a81537cd2fb38f80fbfb8d0f55a4940afb4af7.zip
Added python scripts folder.
Diffstat (limited to 'python')
-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)))