What is the probability of getting equal numbers of heads and tails?

I'm doing my hw, there is a question that I am not sure if I'm correct.
Here is the question

A fair coin is thrown repeatedly.
What is the probability that on the $$n$$ th throw, the numbers of heads and tails to date are equal?

$$\mathrm{The\ required\ situation\ holds\ only\ when} \ n\ \mathrm{is\ even.}\\ \mathrm{Let}\ n=2k,\ \mathrm{then\ the\ required\ probability} = {2k \choose k} \left( \frac{1}{2} \right)^{k} \left( \frac{1}{2} \right)^{k} = {2k \choose k} \left( \frac{1}{2} \right)^{2k} \\ \mathrm{And\ I \ searched\ this\ question\ online\ and\ found\ that\ someone\ said\ that\ the \ probability\ is} \left( \frac{n}{2} \right)\left( \frac{1}{2} \right)^{n}$$ Here is the link: https://www.algebra.com/algebra/homework/Probability-and-statistics/Probability-and-statistics.faq.question.779221.html

I also tried to expand $${2k \choose k}$$ but failed to get the expression $$\left( \frac{n}{2} \right)$$

May I know whether I am correct or where did I do it wrongly, thanks.

• Your answer is correct. The other answer should read $\binom{n}{\frac{n}{2}}\left(\frac{1}{2}\right)^n$, where $n$ is even. – N. F. Taussig Feb 28 at 17:30

The linked answer is wrong even for $$n=2$$. For $$n=2$$ we have $$HT$$ and $$TH$$ as the only possible winning paths, so the answer is $$\frac 12$$. But $$\frac 22\times \left( \frac 12\right)^2=\frac 14$$.
Worth noting that the answer you provide correctly gives $$\binom 21\times \left( \frac 12\right)^2=\frac 12$$
Indeed, your answer is correct for all (even) $$n$$.
Firstly, I think you should also give the (trivial) solution for the case when $$n$$ is odd. For the case where $$n$$ is even your result is correct and the linked answer is incorrect. Presumably what that person meant to say was $${2k \choose k} = {n \choose n/2}$$, because the assertion that $${2k \choose k} = \tfrac{n}{2}$$ is not generally true.