diff --git a/code_study/Baekjoon/js/11653.js b/code_study/Baekjoon/js/11653.js new file mode 100644 index 0000000..c299afb --- /dev/null +++ b/code_study/Baekjoon/js/11653.js @@ -0,0 +1,12 @@ +let N = Number(require("fs").readFileSync(0,"utf8").toString().trim()); + +let n=2; +while(N!==1) { + if(N%n===0) { + console.log(n); + N /= n; + } + else { + n++; + } +} \ No newline at end of file diff --git a/code_study/Baekjoon/js/1978.js b/code_study/Baekjoon/js/1978.js new file mode 100644 index 0000000..abcafdd --- /dev/null +++ b/code_study/Baekjoon/js/1978.js @@ -0,0 +1,19 @@ +const s = require("fs").readFileSync(0,"utf8").toString().trim().split('\n'); +const num = s[1].split(' ').map(Number); +let count = 0; + +for(let n of num) { + if(n==1) continue; + let isPrime = true; + + for(let i=2; i*i<=n; i++){ + if(n%i==0){ + isPrime = false; + break; + } + } + + if(isPrime) count++; +} + +console.log(count); \ No newline at end of file diff --git a/code_study/Baekjoon/js/2501.js b/code_study/Baekjoon/js/2501.js new file mode 100644 index 0000000..8ea073b --- /dev/null +++ b/code_study/Baekjoon/js/2501.js @@ -0,0 +1,12 @@ +let [n, k] = require("fs").readFileSync(0,"utf8").toString().trim().split(' ').map(Number); +let i=1; +while(i<=n){ + if(n%i==0) { + k--; + if(k==0) break; + } + i++; +} + +if(k!=0) console.log(0); +else console.log(i); \ No newline at end of file diff --git a/code_study/Baekjoon/js/2581.js b/code_study/Baekjoon/js/2581.js new file mode 100644 index 0000000..66b4703 --- /dev/null +++ b/code_study/Baekjoon/js/2581.js @@ -0,0 +1,27 @@ +const [m, n] = require("fs").readFileSync(0,"utf8").toString().trim().split('\n').map(Number); +let min = 0, sum = 0; + +for(let num=m; num<=n; num++) { + if(num === 1) continue; + + let isPrime = true; + for(let i=2; i*i<=num; i++) { + if(num%i==0) { + isPrime = false; + break; + } + } + + if(isPrime) { + if(min==0) { + min = num; + } + sum += num; + } +} + +if(sum===0) console.log(-1); +else { + console.log(sum); + console.log(min); +} \ No newline at end of file diff --git a/code_study/Baekjoon/js/5086.js b/code_study/Baekjoon/js/5086.js new file mode 100644 index 0000000..f8cc9ba --- /dev/null +++ b/code_study/Baekjoon/js/5086.js @@ -0,0 +1,7 @@ +const n = require("fs").readFileSync(0,"utf8").toString().trim().split('\n'); +let i=0; +while(true) { + let [a, b] = n[i++].split(' ').map(Number); + if(a==0 && b==0) break; + console.log((b%a==0) ? "factor" : (a%b==0) ? "multiple" : "neither"); +} \ No newline at end of file diff --git a/code_study/Baekjoon/js/9506.js b/code_study/Baekjoon/js/9506.js new file mode 100644 index 0000000..1250fe6 --- /dev/null +++ b/code_study/Baekjoon/js/9506.js @@ -0,0 +1,21 @@ +const n = require("fs").readFileSync(0, "utf8").toString().trim().split('\n').map(Number); +for(let s of n) { + if(s==-1) break; + let str = []; + let sum = 0; + + for(let i=1; i<=s/2; i++) { + if(s%i==0) { + sum += i; + str.push(i); + } + } + + if(sum===s) { + str = s.toString() + " = " + str.join(" + "); + } + else { + str = s.toString() + " is NOT perfect." + } + console.log(str); +} \ No newline at end of file