Suppose you write a program and you send the source code to two of your friends,
and
. Your two friends read the code and when they finish, A errors are detected by
, B errors are detected by
, and C errors are detected by both. So, in total, A+B-C errors are detected and can now be eliminated. We wish to estimate the number of errors that remain unnoticed and uncorrected.
The original version of this problem concerns manuscripts and proofreaders, instead of source code and programmers. It was posed and solved by George Polya and published in 1976 on The American Mathematical Monthly under the name of Probabilities in Proofreading. Because the problem is interesting and Polya’s solution is short and elegant, I have decided to record and share it. Also, since code sharing and reading is a frequent activity in the software development world, estimating the desired value can be helpful for some readers of this blog.
Estimating the number of unnoticed errors
Let E be the number of all errors, noticed and unnoticed, in the source code. Our goal is to estimate the value of E-(A+B-C). Let p be the probability that friend
notices any given error and q the analogous probability for friend
. The expected number of errors that may be detected by
is
and by
is
. Assuming that these probabilities are independent, the expected number of errors that may be mutually detected by both friends is
.
Because we are interested in an estimate, we can safely assume that the expected numbers are approximately equal to the number of errors detected, that is,
,
, and
. (We use the notation
to denote that two numbers are approximately equal.)
We now have all the ingredients to conclude the solution. Recall that our goal is to estimate the value of E-(A+B-C). We calculate:

This is the desired estimate!
Related Articles:

to denote the Fibonacci number
,
to denote the greatest common divisor of
and
to denote the division relation, a possible proof is:
nor
, but applying the distributivity property prioritised the
operator — and we know how to simplify
. Furthermore, in practice, distributivity properties reduce to simple syntactic manipulations, thus reducing the introduction of error and simplifying the verification of our arguments.

. In this post I present a proof that, even if some don’t consider it direct, is a nice example of the effectiveness of calculational proof. But first, there are two concepts that need to be clarified: direct proof and irrational number.
can be something like:
