Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b91bfe0

Browse files
author
zongyanqi
committed
add Easy_492_Construct_the_Rectangle
1 parent b5a02a1 commit b91bfe0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Easy_492_Construct_the_Rectangle.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
* @param {number} area
2929
* @return {number[]}
3030
*/
31-
var constructRectangle = function(area) {
31+
var constructRectangle = function (area) {
3232

33-
};
33+
var w = Math.floor(Math.sqrt(area));
34+
while (area % w != 0) w--;
35+
return [area / w, w];
36+
37+
};
38+
39+
console.log(constructRectangle(4));
40+
console.log(constructRectangle(17));

0 commit comments

Comments
 (0)