Probability of being $\$5$ up after $25$ plays of a game of Heads and Tails (fair coin) In a game of heads and tails with a fair coin - you win $\$1$ if heads; lose $\$1$ if tails - what is the probability of being $\$5$ up after $25$ tosses?
 A: We want to know the probability of getting to $5$ with $25$ plays. The probability of a win is $\text p(W) = 0.5$. Each win adds $+1$ and each loss $-1$. Therefore we have a random walk: each play is independent from the prior, but because we are considering the position in the play $n-1$, and add or subtract the result of play $n$, we build up across plays in the fashion of a random walk, in a way that can be expressed as $\displaystyle \sum_{i=1}^n X_i$, where $X_i$ is a random variable that can take with equal probability the outcomes $\{1,-1\}$, in essence a Bernoulli process. In R we could express it as rw <- cumsum(replicate(25, sample(c(1,-1), 1))); rw[25]:

Among all the possible such random walks we want to know how many are going to land us in the number $5$.
To do so we just need to realize that we need a difference of $5$ between the losses ($L$) and wins ($W$), regardless of the order. If we label the total number of plays as $n$ (in our case $n=25$) and this difference between $W$ and $L$ as $d$ (in our case $d=5$), this relationship will take place provided $n = L + W = \frac{n - d}{2} + \frac{n + d}{2}$. So we need for $L$ to be equal to $\frac{n - d}{2}$ in number. But we can choose these $L$'s among the $n$ total plays - the combinations will be ${n}\choose{(n - d)/2}$, corresponding to all the possible ways we can arrange in time the $\frac{n-d}{2}$ losses among the $n$ zigzags in the random walk (the mathematical combinations) - logically, once these are determined the wins are just the complementary.
Since for every play we can either get $1$ or $-1$, the total number of possible random walks will be $2^n$.
Therefore the probability of getting a result of $d=5$ at the end of the $n=20$ plays is,
$\large \frac{{n}\choose{(n - d)/2}}{2^n} = \frac{{25}\choose{10}}{2^{25}}$$ =0.097 \sim 10\%$.
Instead we can just simulate the game with a  Monte Carlo simulation. Plotting the results of $100,000$ simulations (code in R below):

We get a lot of $0$'s, and values around $0$. In fact, we get a "binomial distribution". The horizontal line at the $10\%$ mark happily coincides with our math calculations for the $\$5$ in the question.
If we calculate the proportion of $5$'s that we get in this computer simulation, we actually get $0.09763 \sim 10\%$, closing the loop - we get to the same spot analytically as now through computer simulation.
Here is the code if you want to try it out in R:
set.seed(0)
mc <- 0
for (i in 1:1e5){
rw <- cumsum(replicate(25, sample(c(1,-1), 1)))
mc[i] <- rw[25]
}
hist(mc,breaks = 40, prob = T, ylim=c(0,0.20), xlim=c(-20,20),
     border = F,
     col = "gray50",
     xlab = "frequency distribution",
     main = "Random Walk Heads Tails Monte Carlo")
abline(h = 0.10)
sum(mc==5)/length(mc)

A: Antoni's answer is better than mine since it has a deeper mathematical underpinning but mine is quicker. Using R the answer comes immediately from looking at the the number of "wins" needed to be "5 up" and using the dbinom function:
> dbinom(15, 25, .5)
[1] 0.09741664

The first argument is the number of wins and the second argument the number of throws. The third argument forces it to be a fair coin although it's not really needed because that is the default value. You can check to see if this makes sense by adding all possible outcomes which should equal unity.
> sum( dbinom(0:25, 25, .5)) # the first argument to dbinom accepts and returns a vector

[1] 1

