Step 1: Let the number of tosses be \(n\).
The number of heads follows a binomial distribution, so the probability of getting \(r\) heads in \(n\) tosses is:
\[
P(\text{r heads}) = \binom{n}{r} \left(\frac{1}{2}\right)^n.
\]
Given that the probability of getting 5 heads is equal to the probability of getting 4 heads, we have:
\[
P(5 \text{ heads}) = P(4 \text{ heads}),
\]
which simplifies to:
\[
\binom{n}{5} \left(\frac{1}{2}\right)^n = \binom{n}{4} \left(\frac{1}{2}\right)^n.
\]
Canceling out \(\left(\frac{1}{2}\right)^n\) from both sides, we get:
\[
\binom{n}{5} = \binom{n}{4}.
\]
From the property of binomial coefficients, we know:
\[
\binom{n}{5} = \binom{n}{n-5},
\]
so the equation becomes:
\[
\binom{n}{5} = \binom{n}{4} \quad \Rightarrow \quad n = 9.
\]
Step 2: Find the probability of getting 6 heads.
Using the binomial distribution for \(n = 9\), the probability of getting 6 heads is:
\[
P(6 \text{ heads}) = \binom{9}{6} \left(\frac{1}{2}\right)^9.
\]
Using the binomial coefficient \(\binom{9}{6} = \binom{9}{3} = 84\), we find:
\[
P(6 \text{ heads}) = 84 \times \frac{1}{2^9} = \frac{84}{512} = \frac{21}{128}.
\]
Thus, the probability of getting 6 heads is \(\boxed{\frac{21}{128}}\).