Birthday paradox

    double p;
	cin>>p;
	int ans = ceil(sqrt(730.0*(log(1/(1-p)))));
	cout<<ans<<endl;

why is this code failing on HB for birthday paradox??(only 6th testcase)

@shameek.agarwal
code gives wrong output when the input is 1
the answer is 367

garbage value is being displayed
add a boundary condition if input is 1

1 Like

for those not getting…expected answer is 366 for 1 (simple pigeonhole)…if 366 people then surely some two people will have birthday on the same day

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.