First off, leap years are not being considered for this. In fact the year that people are born shouldn't be taken into consideration, for simplicity.
The basic question is given an input, a single integer representing the number of people in the room (X >= 1). Return the probability that 2 or more people share the same birthday.
The return from the function should be a value between 0 and 1, inclusive. It should also be rounded out to the 10 thousandth decimal point (4 after the decimal point). There should be no trailing zeros included.
I think there might be something wrong with the test suite. When I run in Matlab, my answers match what the test suite is looking for, yet it still shows a failure.
Ben, your description suggests that rounding to 4 decimal places is optional. Perhaps you can clarify that. Test case with x = 365 is weird. The probability that no one shares a birthday for that x is close to 1.4550e-157 which is neglected during the rounding and hence highly probable event becomes a certainty !!
@Gary What you might be seeing is that the default output from Matlab is only 5 digits (generally). So you're probably seeing something like 0.0027 for X = 2 but if you multiply that answer by 1000 you will see there are still some digits trailing after the 7.
@Venu I think that's just an issue with how I did the calculation on my end. You're right that I should have it as 0.9999 in the test suite even though that is super close to 1 (the actual probability). I'll also make it clear in the brief that the answer should be out to 4 decimal points.
The problem should state truncate at the 10 thousandth point. n=50 is .97037 so the correct rounded answer is .9704 not .9703.
Non-cheating solution!
Cheating solution.
10429 Solvers
Which values occur exactly three times?
3260 Solvers
708 Solvers
Remove from a 2-D matrix all the rows that contain at least one element less than or equal to 4
122 Solvers
Test if two numbers have the same digits
151 Solvers