On the number line, a flea is jumping. It starts from 0, the length of each jump is 1, and the next jump is in the same direction as the previous one with probability $p$, and in the opposite direction with probability $1-p$. What is the probability that it will return to 0?
Solution. Let $q$ denote the probability that the flea returns to 0. By symmetry, we can assume that it initially jumps in the positive direction. Let $r$ denote the probability that it reaches 0 from 1, if it arrived at 1 from 2.

If $p=1$, then $q=0$, it is certain that the flea will not return to 0.

From now on, let's assume that $p \neq 1$. After the first jump, according to our assumption, the flea is at 1, from where it jumps back to 0 with probability $1-p$, and to 2 with probability $p$. In the latter case, the probability that the flea returns to 1 is also $q$. When it arrives at 1 from 2, the probability that it then reaches 0 is $r$. Therefore, the following equation can be written:

$$
q=(1-p)+p q r
$$

Now let's find a similar equation for $r$. After arriving at 1 from 2, it jumps to 0 with probability $p$, and back to 2 with probability $1-p$. From there, similarly to the previous, it returns to 1 with probability $q$ and from there reaches 0 with probability $r$, so

$$
r=p+(1-p) q r
$$

Adding the two equations,

$$
r+q=q r+1
$$

from which, after rearranging and factoring, we get

$$
0=(1-q)(1-r)
$$

This equality holds exactly when $r=1$ or $q=1$. If $r=1$, substituting into (2) we get

$$
1=p+(1-p) q
$$

and thus

$$
(1-p)(1-q)=0
$$

Since $p \neq 1$, it follows that $q=1$, so $q=1$ must definitely hold.

Therefore, if $p \neq 1$, the flea will return to 0 with probability 1, while if $p=1$, it is certain that it will not return.