Created
December 13, 2022 12:08
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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