Cody

# Problem 1267. Calculate the probability that at least two people in a group share the same birthday.

Solution 2141256

Submitted on 26 Feb 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
n = 1; y_correct = 0.00; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

p = 1 p = 1 y = 0

2   Pass
n = 366; y_correct = 1.00; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

3   Pass
n = 0; y_correct = 0.00; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

p = 1 y = 0

4   Fail
n = 23; y_correct = 0.5073; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

p = 1 p = 1 p = 0.9973 p = 0.9918 p = 0.9836 p = 0.9729 p = 0.9595 p = 0.9438 p = 0.9257 p = 0.9054 p = 0.8831 p = 0.8589 p = 0.8330 p = 0.8056 p = 0.7769 p = 0.7471 p = 0.7164 p = 0.6850 p = 0.6531 p = 0.6209 p = 0.5886 p = 0.5563 p = 0.5243 p = 0.4927 y = 0

Assertion failed.

5   Fail
n = 50; y_correct = 0.9704; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

p = 1 p = 1 p = 0.9973 p = 0.9918 p = 0.9836 p = 0.9729 p = 0.9595 p = 0.9438 p = 0.9257 p = 0.9054 p = 0.8831 p = 0.8589 p = 0.8330 p = 0.8056 p = 0.7769 p = 0.7471 p = 0.7164 p = 0.6850 p = 0.6531 p = 0.6209 p = 0.5886 p = 0.5563 p = 0.5243 p = 0.4927 p = 0.4617 p = 0.4313 p = 0.4018 p = 0.3731 p = 0.3455 p = 0.3190 p = 0.2937 p = 0.2695 p = 0.2467 p = 0.2250 p = 0.2047 p = 0.1856 p = 0.1678 p = 0.1513 p = 0.1359 p = 0.1218 p = 0.1088 p = 0.0968 p = 0.0860 p = 0.0761 p = 0.0671 p = 0.0590 p = 0.0517 p = 0.0452 p = 0.0394 p = 0.0342 p = 0.0296 y = 0

Assertion failed.

6   Fail
n = 100; y_correct = 1.0000; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

p = 1 p = 1 p = 0.9973 p = 0.9918 p = 0.9836 p = 0.9729 p = 0.9595 p = 0.9438 p = 0.9257 p = 0.9054 p = 0.8831 p = 0.8589 p = 0.8330 p = 0.8056 p = 0.7769 p = 0.7471 p = 0.7164 p = 0.6850 p = 0.6531 p = 0.6209 p = 0.5886 p = 0.5563 p = 0.5243 p = 0.4927 p = 0.4617 p = 0.4313 p = 0.4018 p = 0.3731 p = 0.3455 p = 0.3190 p = 0.2937 p = 0.2695 p = 0.2467 p = 0.2250 p = 0.2047 p = 0.1856 p = 0.1678 p = 0.1513 p = 0.1359 p = 0.1218 p = 0.1088 p = 0.0968 p = 0.0860 p = 0.0761 p = 0.0671 p = 0.0590 p = 0.0517 p = 0.0452 p = 0.0394 p = 0.0342 p = 0.0296 p = 0.0256 p = 0.0220 p = 0.0189 p = 0.0161 p = 0.0137 p = 0.0117 p = 0.0099 p = 0.0083 p = 0.0070 p = 0.0059 p = 0.0049 p = 0.0041 p = 0.0034 p = 0.0028 p = 0.0023 p = 0.0019 p = 0.0016 p = 0.0013 p = 0.0010 p = 8.4042e-04 p = 6.7925e-04 p = 5.4712e-04 p = 4.3919e-04 p = 3.5136e-04 p = 2.8012e-04 p = 2.2256e-04 p = 1.7622e-04 p = 1.3905e-04 p = 1.0933e-04 p = 8.5668e-05 p = 6.6891e-05 p = 5.2047e-05 p = 4.0354e-05 p = 3.1178e-05 p = 2.4003e-05 p = 1.8413e-05 p = 1.4075e-05 p = 1.0720e-05 p = 8.1353e-06 p = 6.1516e-06 p = 4.6348e-06 p = 3.4793e-06 p = 2.6023e-06 p = 1.9393e-06 p = 1.4398e-06 p = 1.0651e-06 p = 7.8495e-07 p = 5.7635e-07 p = 4.2160e-07 p = 3.0725e-07 y = 0

Assertion failed.

7   Fail
n = 10 y_correct = 0.1169; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

n = 10 p = 1 p = 1 p = 0.9973 p = 0.9918 p = 0.9836 p = 0.9729 p = 0.9595 p = 0.9438 p = 0.9257 p = 0.9054 p = 0.8831 y = 0

Assertion failed.

8   Fail
n = 13 y_correct = 0.1944; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

n = 13 p = 1 p = 1 p = 0.9973 p = 0.9918 p = 0.9836 p = 0.9729 p = 0.9595 p = 0.9438 p = 0.9257 p = 0.9054 p = 0.8831 p = 0.8589 p = 0.8330 p = 0.8056 y = 0

Assertion failed.

9   Pass
n = 2; y_correct = 1/365; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

p = 1 p = 1 p = 0.9973 y = 0

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!