Replace `i*(i+2)` with the faster `(i+1)*(i+1)-1`