Avoid multiplication in loop