Reputation: 1
is there a formula to count each distinct square or rectangle within a rectangle for e.g if we have rectangle of size 105119*753919 , and we want to know how many 54705*91121 in it or how many 2*2 in it , is there a general formula that we can use to get the count ?
Upvotes: 0
Views: 288
Reputation: 4382
In an nm grid, how many ij rectangles?
Answer: as many as places you can put the upper left corner. That is:
(n-i+1)*(m-j+1)
Upvotes: 1