diff --git "a/sik9252/\353\213\244\354\235\214_\355\201\260_\354\210\253\354\236\220.js" "b/sik9252/\353\213\244\354\235\214_\355\201\260_\354\210\253\354\236\220.js" new file mode 100644 index 0000000..a25d57f --- /dev/null +++ "b/sik9252/\353\213\244\354\235\214_\355\201\260_\354\210\253\354\236\220.js" @@ -0,0 +1,12 @@ +function solution(n) { + const countOne = (num) => num.toString(2).split("1").length - 1; + + const target = countOne(n); + let next = n + 1; + + while (countOne(next) !== target) { + next++; + } + + return next; +} diff --git "a/sik9252/\354\210\253\354\236\220\354\235\230_\355\221\234\355\230\204.js" "b/sik9252/\354\210\253\354\236\220\354\235\230_\355\221\234\355\230\204.js" new file mode 100644 index 0000000..b54c1e4 --- /dev/null +++ "b/sik9252/\354\210\253\354\236\220\354\235\230_\355\221\234\355\230\204.js" @@ -0,0 +1,22 @@ +function solution(n) { + let answer = 0; + let left = 1; + let right = 1; + let sum = 1; + + while (left <= n) { + if (sum === n) { + answer++; + sum -= left; + left++; + } else if (sum < n) { + right++; + sum += right; + } else { + sum -= left; + left++; + } + } + + return answer; +}