Skip to content

Instantly share code, notes, and snippets.

@doingthisalright
Created December 13, 2022 12:08
Show Gist options
  • Save doingthisalright/f0ea7919004a7756c49abf38709f65f2 to your computer and use it in GitHub Desktop.
Save doingthisalright/f0ea7919004a7756c49abf38709f65f2 to your computer and use it in GitHub Desktop.
Total Number of all sized Squares in a Rectangle of size X x Y
function getTotalSquares(x, y) {
let total = 0;
for (let loop = 0; loop < Math.min(x, y); loop++) {
total += ((x-loop) * (y-loop));
}
return total;
}
console.log(getTotalSquares(4, 11));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment