TITLE: Probability of remaining a whole pancake rather than two halves.
QUESTION [9 upvotes]: A very interesting question. It is trivial for small number of pancakes but for 100 I was not able to find an analytical or manual way to figure out the probability. Thanks a lot in advance if you can share your ideas!

Suppose you have 100 pancakes to eat. Everyday you eat a half of a pancake. In this way after one day there will remain 99 whole pancakes and a half pancake. Suppose your choice of the pancake is random. That is, you are equally likely to pick any remaining pancake, no matter it is a whole pancake or a half pancake, to eat everyday. Formally, if there are $X$ whole pancakes and $Y$ half pancakes at the beginning of some day, then the probability of each piece of pancake to be picked is $\frac{1}{X+Y}$. Then what's the probability of the event that after $99\times 2 = 198$ days of eating, there will remain a whole pancake rather than 2 halves of pancakes?

Notice that the question might be interpreted in another way, as @Acccumulation noted in his answer. So please be careful about the interpretation.
For example, denote the index of the day by $k$, and the number of whole pancakes at (the end of) day $k$ as $X_k$ (i.e., after you eat the pancake), then $P(X_0 = 100) = 1$, $P(X_1 = 99) = 1$, $P(X_2 = 99) =1/100, P(X_2 = 98) = 99/100 $.
If we denote the number of half pancakes at (the end of) day $k$ as $Y_k$, then it's easy to see that $2X_k + Y_k + k = 200$ and 
$$P(X_{k+1} = X_k - 1) = \frac{X_k}{X_k+Y_k}, P(X_{k+1} = X_k) = \frac{Y_k}{X_k+Y_k}.$$
Or equivalently,
$$P(X_{k+1} = X_k - 1) = \frac{X_k}{200-k-X_k}, P(X_{k+1} = X_k) = \frac{200-k-2X_k}{200-k-X_k}.$$
However, this relationship depends on both the values of $X_k$ and $k$, which is hard to use for recursion by hand. Does anyone have some ideas to do recursion or go in some other directions? Thanks a lot!

REPLY [3 votes]: Here's a method that provides the exact answer $(0.14218003717754\ldots)$, which as a fraction in lowest terms has a numerator and denominator with $3189$ decimal digits each.
For convenient notation, we can represent $n$ pancakes by a string of $n$ numbers, where each number represents how many halves of the corresponding pancake are present, removing any $0$s as they occur. The procedure is then as follows:

Start with a string of $n\ 2\text{s}$ and repeat the following steps $2n-2$ times.
Choose a position in the string uniformly at random.
Subtract $1$ from the number in the chosen position.
If the subtraction gives $0$, then remove that element from the string.

The question equivalent to the OP's is whether the result of the procedure is the string $2$ (representing a whole pancake) or the string $11$ (representing halves of two different pancakes).
Let pS (where S is a string) denote the probability that repeating the steps 2-3-4 eventually reduces S to $2$. Then we find the following system of equations by constructing the relevant trees of possible paths, noting those that reach string $2$:
p2 = 1

p12 = (1/2)*p2
p22 = p12

p112 = (2/3)*p12
p122 = (1/3)*p22 + (2/3)*p112
p222 = p122

p1112 = (3/4)*p112
p1122 = (2/4)*p122 + (2/4)*p1112
p1222 = (1/4)*p222 + (3/4)*p1122
p2222 = p1222

p11112 = (4/5)*p1112
p11122 = (3/5)*p1122 + (2/5)*p11112
p11222 = (2/5)*p1222 + (3/5)*p11122
p12222 = (1/5)*p2222 + (4/5)*p11222
p22222 = p12222

p111112 = (5/6)*p11112
p111122 = (4/6)*p11122 + (2/6)*p111112
p111222 = (3/6)*p11222 + (3/6)*p111122
p112222 = (2/6)*p12222 + (4/6)*p111222
p122222 = (1/6)*p22222 + (5/6)*p112222
p222222 = p122222

etc.

Here's a picture for the case of p222, where the number over an arrow indicates the number of equally likely cases with only one of the cases shown (e.g. here 222 may become any one of the three equally likely 122, 212, or 221, and only 122 is shown, etc.):

Thus, the probabilities of interest (i.e. p22, p222, p2222, etc.) are all determined by the above equations, with initial condition p2 = 1. This system of equations can be written as the following recursion, with $n\ge1,\ 0\le i\le n-1$:
$$\begin{align}P_i^{(n)} &= \begin{cases}
1, & \text{if}\ \ n=1,\ i=0\\[2ex]
{n-1\over n}P_0^{(n-1)}, & \text{if}\ \ n>1,\ i=0\\[2ex]
{n-(i+1)\over n}P_i^{(n-1)}+{i+1\over n}P_{i-1}^{(n)}, & \text{if}\ \ n>1,\ 0<i<n-1\\[2ex]
P_{n-2}^{(n)}, & \text{if}\ \ n>1,\ i=n-1.\\
\end{cases}
\end{align}$$
Here $P_i^{(n)}=$pS$_i^{(n)}$, where S$_i^{(n)}$ is any string composed of $i+1\ 2s$ and $n-(i+1)\ 1s$, so the probability that answers the OP's question is $P_{n-1}^{(n)}$ with $n=100$.
These equations can be programmed (in Sage) as follows, using iteration rather than recursive function calls in order to compute the case $n=100$ in a reasonable amount of time ... 
def next(L): # routine to be iterated   
# input the list L of n probabilities 
# output the list M of n+1 probabilities
    n = len(L) + 1
    M = [0]*n
    M[0] = L[0]*(n-1)/n
    for i in [1..n-2]: M[i] = L[i]*(n-i-1)/n + M[i-1]*(i+1)/n
    M[n-1] = M[n-2]
    return M

def prob(n): # iterate next() n-1 times, starting with L = [1]
# return the desired probability for a starting string of n 2s
    L = [1]
    for _ in [1..n-1]: L = next(L)
    return L[-1]

for n in [1..100]:
    p = prob(n) 
    print n, p.n(), p

Some output:
  1 1.00000000000000 1
  2 0.500000000000000 1/2
  3 0.388888888888889 7/18
  4 0.336805555555556 97/288
  5 0.305538888888889 54997/180000
  6 0.284236419753086 460463/1620000
  7 0.268560305649710 51185279267/190591380000
  8 0.256411353406832 200170674968477/780662292480000
  9 0.246639514750182 11369422537341929933/46097327708651520000
 10 0.238557094011412 6873027837417268175729/28810829817907200000000
 20 0.196966565034451             116 digits/116 digits
 50 0.161160193091085             793 digits/794 digits 
100 0.142180037177541            3189 digits/3189 digits
200 0.127470565382368           13921 digits/13921 digits
500 0.112388292456287           86903 digits/86904 digits

NB: Monte Carlo simulations verify these results to three decimal places for $n$ up to $100$.

NB: The above answer uses a recursion different from the "simpler" one mentioned by @lulu in a comment, but they are equivalent in the sense of yielding exactly the same probabilities. However, neither recursion allows a feasible computation of the case $n=100$ unless recursive function calls (and exponentially increasing execution times) can be avoided by using iteration instead -- and I was unable to do so with the "simpler" recursion. For reference, the following is an implementation (in Sage) of @lulu's recursion using recursive function calls, where $P(n,m)$ is the probability that a state $(n,m)$ (i.e. $n$ whole pancakes and $m$ halves)  eventually reaches the state $(1,0)$ (i.e., one whole pancake and no halves):
$$\begin{align}
P(n,m) &= \begin{cases}
0,&\text{if}\ \ m\ge0,n=0\\[2ex]
\frac n{n+m} P(n-1,m+1)+\frac m{n+m} P(n,m-1), & \text{if}\ \ m>0,n>0\\[2ex]
P(n-1,m+1),& \text{if}\ \ m=0,n>1\\[2ex]
1,&\text{if}\ \ m=0,n=1\\[2ex]
\end{cases}
\end{align}$$
def P(n,m):
    if n==0: return 0
    if n==1 and m==0: return 1
    if m==0: return P(n-1,m+1)
    return (n/(n+m))*P(n-1,m+1) + (m/(n+m))*P(n,m-1)

Now P(n,0) equals prob(n), but on my system the execution time for P(n,0) is at least $3.6$ times that for P(n-1,0), and P(100,0) would require more than $10^{45}$ hours (compared to less than $1$ second for the iterativeprob(100)).