Skip to content

Commit 2d5fa29

Browse files
committedJan 20, 2020
Add solution #263
1 parent 15b6226 commit 2d5fa29

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed
 

‎solutions/0263-ugly-number.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
* @return {boolean}
1414
*/
1515
var isUgly = function(num) {
16-
if (num < 1) return false;
17-
while (num % 5 === 0) num /= 5;
18-
while (num % 3 === 0) num /= 3;
19-
while (num % 2 === 0) num /= 2;
16+
for (let i of [2, 3, 5]) {
17+
while (num && num % i === 0) num /= i;
18+
}
2019
return num === 1;
2120
};

0 commit comments

Comments
 (0)
Please sign in to comment.