As a first step understand what the innermost loop does:
Code: Select all
for(int k = 0; k < 3; k++){
c++;
if(k>j)
break;
}
Code: Select all
sum{ 1: 0 <= k < = j + 1} = j + 2
- or sum it up using an equivalent math formula -
Code: Select all
for(int i = 0; i < 2; i++){
for(int j = 0; j < 2; j++){
c += j + 2;
}
}
Code: Select all
sum { j + 2 : j = 0,1} = 5
c = sum { 5 : i = 0,1 } = 10.