From 67a81537cd2fb38f80fbfb8d0f55a4940afb4af7 Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Sun, 13 Dec 2020 15:00:41 +0100 Subject: Added python scripts folder. --- python/cumples.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 python/cumples.py (limited to 'python') 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))) -- cgit v1.2.1