While there are many different complicated equations and calculations that can be made for weight gain, one of the simplest is to eat 500 more calories a day than you burn. To figure out how many calories you burn daily while you're resting, multiply your weight by 11 to find your REE or Resting Energy Expenditure. For example, I'm 170 pounds. So 170 x 11 would be 1870 calories burned daily just through breathing and being alive. These numbers tend to fluctuate when you add in activity levels but if I wanted to gain weight I'd have to consume around 2300 calories a day on days with low activity levels. Here's a frame of reference for figuring out caloric intake based on different activity levels. (Resting Energy Expenditure x Activity Level = Recommended Caloric Intake)
- Very Light - Seated or standing activities, driving, or playing video/card games fall into this category. Multiply your REE x 1.3.
- Light - Walking, sailing, carpentry, or golfing fall into this category of activity. Multiply your REE x 1.6
- Moderate - Carrying moderately heavy objects, jogging, light swimming, biking, and body-weight exercises fall into this category. Multiply your REE x 1.7
- Heavy - Carrying loads uphill, rowing, digging, climbing, running and most sports fit into this category. Multiply your REE x 2.4
- Exceptional - Running/swimming races, carrying heavy loads uphill, biking uphill, hard rowing fall into this category. Multiply your REE x 2.7
Sleep is a very overlooked, but equally important component in weight gaining. When you sleep your body goes into a anabolic or regenerative state. It recovers from exercises during the day, and builds new muscle tissue. While you're sleeping your body also is outputting it's maximal amount of growth hormone. Sleep is also very important to your brain. While you sleep it replenishes multiple neurotransmitters that you need for a active lifestyle. A lack of sleep could result in loss of focus, motivation, or attention. It could also cause depression and a overall lack of energy. Sleep is a very very vital function and it's recommended that you get between 8-10 hours every night.
This brings us to our last, but certainly not least important weight gain component. That is the routine. Weight Training is hands down the best way to gain muscle mass. Compound Exercises that utilize more than 1-2 muscle groups are ideal for mass gaining. This includes but isn't limited to the big three (squats, deadlifts, and bench presses) overhead presses, clean and presses, dips, and pull-ups. I'd recommend following the guidelines in my article outlined here for hypertrophy if you're looking to get big.
In short, Lift Hard, Eat Big, and Sleep Well. These things will allow you to gain muscle fast and efficiently. Remember that trying to lose weight and gain muscle at the same time is like taking two steps forward, and one back. Instead you could focus on eating above caloric expenditure, and focus on training hard without worrying much about the little bit of extra fat that comes with it. It's much easier to lose weight, than to gain muscle.