You are watching: Number of squares in a grid

Suppose $nge m$.Number of squares of size 1: $mcdot n$Number of squares of size 2: $(m-1)cdot (n-1)$...Number of squares of size m: $1cdot (n-m+1)$

Result: $$eginalignsum_k=1^m k cdot (n-m+k) & =(n-m)sum_k=1^m k +sum_k=1^m k^2 \& = (n-m) m(m+1)/2 + m(m+1)(2m+1)/6 \& = fracm(m+1) (3n-m+1)6endalign$$

Rectangles in rectangle$$frac(n^2+n)(m^2+m)4$$

Rectangles in square$$frac(n^2+n)^24$$

Squares in rectangle$$m≥ n-1,frac(n^2+n)2m-frac(n^3-n)6$$

Squares in square$$frac(n^2+n)(2n+1)6$$

Thanks for contributing an answer to barisalcity.orgematics Stack Exchange!

Please be sure to*answer the question*. Provide details and share your research!

But *avoid* …

Use barisalcity.orgJax to format equations. barisalcity.orgJax reference.

See more: Sears Roebuck And Co Pocket Watch 16, 2 Illinois Sears Roebuck Co

To learn more, see our tips on writing great answers.

Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

## Not the answer you're looking for? Browse other questions tagged combinatorics or ask your own question.

What is the number of squares in an $N imes M$ grid, if the squares don't have to be aligned with the grid's axes?

What is the number of squares in an $N imes M$ grid, if the squares don't have to be aligned with the grid's axes?

How many subsets of squares in a $3 imes 3$ grid, corners requiring both adjacent squares to be included?

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev2021.10.14.40450

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.