Regarding probability and the birthday paradox

If by exaclty you mean any two peaople having same birthday and all the rest having different birthday, then we can do it for ingeneral having $i$ peaople out of $k$ with same birthday as follows:

For each fixed day of 365 days there are $\binom{k}{i}$ ways of chosing $i$ people having that day as birthday, by wich there are $364(364-1)(364-2)\ldots(364-k+i+1)$ ways of the rest $k-i$ people having different birthday, so the probability of exactly $i$ having the same birthday is $$P(i)=\frac{365\binom{k}{i}364(364-1)(364-2)\ldots(364-k+i+1)}{365^k}$$


The denominator is still going to be $365^k$.

In the numerator, we have:

  • $365$ ways to choose the repeated birthday;
  • $\binom{364}{k-2}$ ways to choose the birthdays that are not repeated;
  • $\frac12 k!$ ways to permute the resulting days, dividing by $2$ because the two repeated birthdays can be swapped.

So we get a probability of $$\frac{365 \cdot\binom{364}{k-2} \cdot \frac12 k!}{365^k} = \frac{k! \binom{364}{k-2}}{2 \cdot 365^{k-1}}.$$ Set $k=23$ to get the probability you want.


Another option for the numerator, which will get an equivalent answer. First, there are $\binom k2$ ways to choose which two people have the same birthday. Then, we can take the same product $365 \cdot 364 \cdot 363 \cdots$ to fill in the birthdays, but there is one difference. Once we pick the birthdays of one person in the repeated pair, we get the other one for free. So instead of having the $k$-factor product $365 \cdot 364 \cdots (365-k+1)$, we get the $(k-1)$-factor product $365 \cdot 364 \cdots (365-k+2)$.

The result is $$ \frac{\binom k2 \cdot 365 \cdot 364 \cdots (365-k+2)}{365^k}. $$