A closed formula for the evaluation of foams