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

Commit 5f2efdf

Browse files
Add 다음-큰-숫자.js
1 parent f2ca23f commit 5f2efdf

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎level-2/다음-큰-숫자.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,15 @@ function solution(n) {
3030
const countOne = (str) => {
3131
return str.split('').reduce((sum, currentChar) =>
3232
currentChar === '1' ? sum += 1 : sum, 0)
33+
}
34+
35+
//정답 3 - prove-ability
36+
function solution(n) {
37+
let i = n;
38+
n = n.toString(2).match(/1/g).length;
39+
while(true) {
40+
i++;
41+
const value = i.toString(2).match(/1/g).length;
42+
if(n === value) return i;
43+
}
3344
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /