All problems
No Shared Birthday Probability
Problem
The probability that n people all have distinct birthdays among d equally likely days is prod_{i=0}^{n-1} (d - i) / d.
Given n and d (default 365), return the probability; return 0.0 when n > d.
Hint
Multiply the conditional probabilities of avoiding each previous birthday.
Test cases
case 1
in: [3,365]
expected: 0.9917958341152187
case 2
in: [2,4]
expected: 0.75
case 3
in: [5,3]
expected: 0
Starter codePython
def no_shared_birthday_probability(n, days=365):
# Your code here
pass3 test cases · run your code against them in the editor