In the very first iteration all the four variables have values =0.
In the sum expression the value of index at some place is coming out to be negative due to which answer is coming wrong.
Sum of all submatrix from a given matrix approach 2
but sir if i make them zero then
suppose i consider 2X2 matrix with all elements 1.
consider sub matrix of elements at (0,0) and (0,1) the sum must be 2 but we will get 0