Cody

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

Solution 557481

Submitted on 14 Jan 2015 by Abdullah Caliskan
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)

ans = 0

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

ans = 1

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

ans = 0

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

[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits] [> In nchoosek at 92 In birthday_prob at 5 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] ans = 0.5100

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

[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits] [> In nchoosek at 92 In birthday_prob at 5 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] ans = 0.9700

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

[Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits] [> In nchoosek at 92 In birthday_prob at 5 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] ans = 1

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

n = 10 [Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits] [> In nchoosek at 92 In birthday_prob at 5 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] ans = 0.1200

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

n = 13 [Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits] [> In nchoosek at 92 In birthday_prob at 5 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] ans = 0.1900

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

ans = 0