There is an estimate for the number of bugs in a program that is called the Lincoln Index. It is really easy to calculate.
There is a great explanation on this here:
http://leankit.com/blog/2015/12/how-many-bugs-are-left-the-software-qa-puzzle/
Additionally:
And something related:
https://en.wikipedia.org/wiki/German_tank_problem