Created
March 5, 2024 14:46
-
-
Save NedaMani/336835aec6d23ab150a3018ae149ed6a to your computer and use it in GitHub Desktop.
rectanglesInsideRectangle
This file contains hidden or 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
const rectanglesInsideRectangle = (M, N) => { | |
let rectangles = (M*(M+1)/2) * (N*(N+1)/2); | |
let min = Math.min(M, N); | |
let squares = min*(min+1)*(2*min+1)/6; | |
return rectangles + squares; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment