Well it takes 3500 calories in excess of your normal intake needs to gain 1 lb of weight. As far as solely gaining muscle with no fat, it's my understanding that depends on the kind of food you're eating.
As a general rule, just multiply your bodyweight x 18 and that's how many calories you need.
I.E. 180 pounds x 18 = 3,240 calories.
Many others will claim that you need more, and if you're doing the work in the gym then the more the better, but I use this as a good general outline for calorie counting. Still others will think that 3,240 is way to low for someone of 180 pounds, however try putting that many calories into your body with a busy schedule (WITHOUT exaggerating or rounding up to the nearest hundred calorie) and you'll start to respect this calculation a little more.
Lower towards 15 for slower metabolisms and higher towards 20 for faster metabolisms.
According to the Greek legend, there was an innkeeper named Procrustes who was obsessed with having his guests fit in his bed. If his guests were shorter than the length of the bed, he stretched them out until they fit. If they were too tall, then he chopped their feet off.
I require about 22 per pound to maintain without working out and probably about 26 per pound to gain 1/2 pound per week. I lose 1 pound per week on 18 kcal per pound. If I go to an intake of 15 kcal per lb, I tend to quickly gauld my muscle mass. Been there done that on my fat loss program. I always wondered why I required more calories than the average person, or why most calculators calculated my requirements lower than what they actually were. Not sure why this is.