It is a simple matter of calories in vs calories out. Calculating the calories out is the hard part, and things like when you eat and what you eat can influence the calories out, but it still is a simple matter of in>out = weight gain vs out>in = weight loss.