Skip to content

Commit

Permalink
#13 24.01.01 > 숫자 블록
Browse files Browse the repository at this point in the history
  • Loading branch information
beurmuz committed Jan 1, 2024
1 parent d4e88dc commit a1f2664
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/programmers/Lv_2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,4 @@
| 87 | [우박수열 정적분](./math.js) | 23.12.14 | X | [23.12.18](./replay/math.js) |
| 88 | [더 맵게](./spicy.js) | 23.12.22 | X |
| 89 | [이모티콘 할인 행사](./emoji.js) | 23.12.31 | X |
| 90 | [숫자 블록](./numsBlock.js) | 24.01.01 | X |
22 changes: 22 additions & 0 deletions src/programmers/Lv_2/numsBlock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function findMaxDivisor(num) {
if (num === 1) {
return 0;
}

for (let i = 2; i <= Math.sqrt(num); i++) {
if (num % i === 0 && num / i <= 1e7) {
return num / i;
}
}
return 1;
}

function solution(begin, end) {
let answer = [];

for (let i = begin; i <= end; i++) {
answer.push(findMaxDivisor(i));
}

return answer;
}

0 comments on commit a1f2664

Please sign in to comment.