# Calculate the probability of n of the same event happening first

I can work out the probability of two unequal events, such as a coin that lands on heads 40% of the time and tails the other 60%. If I want to work out the likelihood of 1 head happening before 2 tails it's $0.4 + 0.6 \times 0.4 = 0.64$. The opposite case is $0.6 \times 0.6 = 0.36$. The two cases add up to 100% so they should be correct.

However, I want to calculate the probability of 1 of $x$ events happening $n$ times before any of the other events. $n$ is potentially different for each event, as is the probability of any event happening each time. For example, an unbalanced die will land on one of its six faces but not with the same probability. What if I wanted to find out which is likely to happen first:

event  times  probability
1       5     0.12
2       5     0.13
3       4     0.15
4       6     0.10
5      20     0.24
6      15     0.26


All I can work out is that it will take at least 4 rolls (only if they're all 3) and no more than 50 rolls (the sum of $n-1$ for all rolls is 49) but not the probability of each case. How can I make this a general formula for any number of events (i.e. not only 6 faces of a die but 3 events, 10 events, etc.), any number of times and any probability for each event?