Computing work for loops