Consider the following probability puzzle.
We start with a string of bits all set to 0. At each step we choose a bit uniformly and independently at random and flip it. The value your code has to compute is the probability of getting to the all 1s bit string before you get back to the all 0s bit string.
Let \$n\$ be the length of the starting bitstring.
\$n = 1\$. The output is 1.
\$n = 2\$. The output is 1/2.
\$n = 3\$. The output is 2/5.
The remaining outputs for n up to 20 are:
Your code should take \$n\$ as the input and give the right output. The output must be exact, for example as a fraction. There is no need for the fraction to be fully reduced.
Your code must work for \$n\$ up to at least \$20\$ and run without timing out on TIO .