Term calculation and sum