Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb91bfe0

Browse files
author
zongyanqi
committed
add Easy_492_Construct_the_Rectangle
1 parentb5a02a1 commitb91bfe0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

‎Easy_492_Construct_the_Rectangle.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
*@param {number} area
2929
*@return {number[]}
3030
*/
31-
varconstructRectangle=function(area){
31+
varconstructRectangle=function(area){
3232

33-
};
33+
varw=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)

[8]ページ先頭

©2009-2025 Movatter.jp