intermediate calculation for task d)