What's the probability formula for getting $k$ possibly-non-consecutive successes before $r$ failures in a sequence of independent Bernoulli trials?

Before I begin, I should mention that this Q&A doesn't answer this question.

I'm trying to determine the probability of getting $k$ successes before $r$ failures where the successes may not necessarily be consecutive.

Specifically, I want to determine how this page got the following probabilities on a 1d20 as repeated on the table below. (Column "S" is the probability for a single trial, while columns "3", "5", and "10" refer to having that many successes before the 3rd failure.)

  S  | 3      | 5      | 10
-----+--------+--------+---------
95% | 99.88% | 99.62% | 98.04 %
75% | 89.65% | 75.64% | 37.07 %
50% | 50   % |  2.66% |  1.93 %
25% | 10.35% |  1.29% |  0.004%
5% |  0.12% |  0   % |  0    %


It's not the Negative Binomial Distribution.

1-NEGBINOMDIST(3,3,95%) = 99.8928% (which is different from the table)

1-NEGBINOMDIST(3,5,95%) = 99.9994% (which, again, is different from the table)

It's plausible that the table is wrong, but I doubt it.

It's the SUM of the Negative Binomial Distributions, running from 0 failures to "the # of allowed failures" - 1.

For example:

  | A                         | B
--+---------------------------+--
1 | # of Required Successes   | 3
2 | Trial Success Probability | 95%
3 | Before 1 Failure          | =NEGBINOMDIST(0,B1,B2)
4 | Before 2 Failures         | =B3+NEGBINOMDIST(1,B1,B2)
5 | Before 3 Failures         | =B4+NEGBINOMDIST(2,B1,B2)


They appear to be computing the probability that the third (or some other number) of the successes comes before the third failure. This is the probability of $k$ or more successes (or equivalently $2$ or fewer failures) in the first $k+3-1$ trials.

The clue is the answer $0.5$ when the probability of success is $0.5$. I have checked that the approximate answer for $3$ and $3$ really is close to $0.9988$.