1
$\begingroup$

I have a question regarding the code to solve a particular equation. This is the equation:

364! / [(365-n)! * 365^(n-1)] <= 0.5 

and I need to solve for n.

The code I used is:

Clear[n];
Solve[364!/{(365-n)! 365^(n-1)} <= 0.5, n]

However, it's not solving for n and only expanding 364! with the rest of the equation as it is. Can anyone point out if I'm making a mistake in the code?

$\endgroup$
  • $\begingroup$ You are using {} and [] parenteses, where you need () $\endgroup$ – Coolwater Sep 14 '15 at 7:30
  • 1
    $\begingroup$ The solution set is infinite... but give Solve[364!/((365 - n)! 365^(n - 1)) <= 1/2 && 0 <= n <= 365, n, Integers] a spin, and ArgMin[{Abs[364!/((365 - n)! 365^(n - 1)) - 1/2], 0 <= n <= 365}, n, Integers] might be more what you're after. $\endgroup$ – ciao Sep 14 '15 at 7:41
1
$\begingroup$

For this ("birthday puzzle"), it just easy enough to visualize and "solve immediately" (i.e brute force), e.g.

f[n_] := N[364!/((365 - n)! 365^(n - 1))]
DiscretePlot[f[n], {n, 0, 30}, GridLines -> {None, {1/2}}, 
 Frame -> True]

enter image description here

n->23 or

TableForm[Table[{j, f[j]}, {j, 20, 25}], 
 TableHeadings -> {None, {"n", "f[n]"}}]

enter image description here

$\endgroup$
  • $\begingroup$ And now the probability that at least three people (in general m people) share a common birthday. ;-) $\endgroup$ – Dr. Wolfgang Hintze Sep 14 '15 at 11:07
  • $\begingroup$ math.ucdavis.edu/~tracy/courses/math135A/UsefullCourseMaterial/… $\endgroup$ – ubpdqn Sep 14 '15 at 12:20
  • $\begingroup$ @Dr.WolfgangHintze tricky indeed :) hyperlink above $\endgroup$ – ubpdqn Sep 14 '15 at 12:21
  • $\begingroup$ @Dr.WolfgangHintze: Trivial, just a multinomial... or do you mean the reverse problem (number to have >=.5 p)? $\endgroup$ – ciao Sep 14 '15 at 21:38
  • $\begingroup$ @ciao yes the joy of multinomials...too busy lately...hoping for clear air to play but nothing on horizon...:) $\endgroup$ – ubpdqn Sep 14 '15 at 21:53
1
$\begingroup$

Try this:

    FindRoot[364!/((365 - n)!*365^(n - 1)) == 0.5, {n, 25}]

(*  {n -> 22.7677}   *)

Have fun!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.