It’s just the p-value calculation for the binomial distribution.
If you have some statistics software, you can get it easily, e.g. in R:
> pbinom(135,1340,0.2)
[1] 6.495024e-23
Otherwise, you could calculate it manually summing over the appropriate range of binomial pdf, e.g.
sum from x=0 to 135 (1340 choose x)*0.2^x*(1-0.2)^(1340-x)
Wolfram alpha can calculate this if you punch it in there
If you want a more detailed explanation, it’s actually fairly intuitive if you break it down. The binomial distribution (and related geometric and negative binomial distributions) are all fairly intuitive to calculate if you understand basic probability math.
I’ll illustrate it for simpler numbers, e.g. x=2 successes on n=20 trials with p=20%. If the chance of success is 20%, then the chance of failure on a given trial is 1-p, in this case 80%.
The probability of getting 2 successes on the first 2 trials, followed by 18 failures on the remaining trials is 0.2*0.2*0.8*0.8*0.8*0.8*0.8*0.8*0.8*0.8*0.8*0.8*0.8*0.8*0.8*0.8*0.8*0.8*0.8*0.8, or more succinctly, 0.2^2*0.8^18. In general terms, this can be expressed as p^x*(1-p)^(n-x) where n is the total number of trials, x is the number of successes, and p is the probability of success on a trial.
Now that’s specifically for the case where you get success on the first two trials, followed by 18 failures. There’s lots of other ways to get 2 successes on 20 trials. You could have successes on trials 2 and 9, with failures on the other 18 trials. That would have probability 0.8*0.2*0.8*0.8*0.8*0.8*0.8*0.8*0.2*0.8*0.8*0.8*0.8*0.8*0.8*0.8*0.8*0.8*0.8*0.8. It should be easy to see this is the same product as above, just rearranged, and simplified it’s still 0.2^2*0.8^18.
We could do it for other combinations of trials, e.g. successes on trials 3 and 12, but it should be easy to see all of the possible combinations of 2 successes on 20 trials have the same probability, 0.2^2*0.8^18.
So to get the total probability of getting 2 successes on 20 trials, we could count up all the combinations of pairs of trials with 2 successes. There’s lots of them, Successes on trials {1,2}, {1,3}, {1,4}, …, {18,19}, {18,20}, {19,20}. It’d be pretty tedious to count up all these manually, especially for larger numbers like 135 successes on 1340 trials. But it turns out there’s a nice simple way to calculate this. It’s called a combination, and it’s calculated as 20!/(2!18!) = 190, i.e. here are 190 different ways to get 2 successes on 20 trials. This is commonly called the choose function, i.e. (20 choose 2) = 20!/(2!18!). To find the number of combinations of k successes on n trials, it’s just (n choose k) = n!/(k!(n-k)!.
So then to get the total probability, we can multiply the number of combinations by the probability of an individual combination, i.e. (20 choose 2)*0.2^2*(1-0.2)^(20-2) = 0.137. There’s a 13.7% chance of getting exactly 2 successes on 20 trials.
In more general terms for arbitrary n,x,p we have (n choose x)*p^x*(1-p)^(n-x). And that’s it, that’s the pdf (probability function) of the binomial distribution. The probability of getting exactly x successes on n trials with probability p is (n choose x)*p^x*(1-p)^(n-x).
To get the probability of k or fewer successes on n trials with probability p, we sum over x from 0 to k. This is just the p-value for the binomial distribution, i.e. sum from x=0 to k (n choose x)*p^x*(1-p)^(n-x).
For our case with 2 successes on 20 trials, we’d be summing the probabilities to get 0, 1, or 2 successes.
sum from x=0 to 2 (20 choose x)*0.2^x*(1-0.2)^(20-x) = 0.206, i.e. there is a 20.6% chance to get 2 or fewer successes on 20 attempts if the true probability of success is 20%.
In this case, with n=1340, k=135, p=0.2, we have what I showed above:
sum from x=0 to 135 (1340 choose x)*0.2^x*(1-0.2)^(1340-x) = 6.495x10^-23