algorithms, number of instructions in the code How many instructions as a function of the input size N?

int count=0;
for (int i=0; i&lt;N; i++)
  for(int j=i+1; j&lt;N; j++)
    if(a[i] + a[j] ==0)
       count++;


# of "less than" compare instructions  = 1/2(N+1)(N+2)   Can someone pl. explain why there is 1/2 multiplier? 

# of "equal to" compare instructions = 1/2 * N * (N-1). 
The same here why is there 1/2 * (N-1). Shouldn't it be just N?

also when do we increment j++?, after count++ or after we increment i?

Thank you!
The factors of $\tfrac12$ come from the fact that $1 + \dots + N = \tfrac12N(N+1)$.

j is incremented at the end of the loop. This is standard syntax for languages such as C and Java.