Software like ProMash makes your life much easier in this regard.

You can download a trial version.
Basically, each ingredient has an SG rating that indicates what it would contribute to the wort if you extracted 100%. Based on that number, the volume of wort and the gravity, you can determine your efficiency.
I don't know the actual formula off the top of my head because I just use software. You can find this and many other formulas in the book "Designing Great Beers". It has all kinds of technical formulas and whatnot for every aspect of your beer.
Cheers
