In a game, you start with K coins. On each turn, a coin is flipped. If heads, you gain a coin; if tails, you lose one coin. Turns are played continuously until either you have 0 coins (you lost), or K + X coins, for a fixed X (you won).
How can I calculate the probability P(K, X) of losing/winning?
If the coin flips are fair, your expected number of coins must always remain the same: $K$. Let the probability of winning (i.e., reaching $K+X$ before reaching $0$) be $P_{K,X}$. Then $$ K = P_{K,X}\cdot (K+X) + (1-P_{K,X})\cdot 0, $$ or $$ P_{K,X} = \frac{K}{K+X}. $$