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 f6fcaa9

Browse files
solve: 콜라츠 수열 만들기
1 parent a97b1e1 commit f6fcaa9

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

‎Level0/PRO181919.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Solution 1
2+
const getCollatzNum = (num) => {
3+
return num % 2 === 0 ? num / 2 : 3 * num + 1;
4+
};
5+
6+
const solution = (n) => {
7+
const collatzSequence = [n];
8+
9+
while (n !== 1) {
10+
const collatzNum = getCollatzNum(n);
11+
12+
collatzSequence.push(collatzNum);
13+
n = collatzNum;
14+
}
15+
16+
return collatzSequence;
17+
};

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,4 @@
292292
| 23.11.21. | `Level 0` | [문자열 묶기](https://school.programmers.co.kr/learn/courses/30/lessons/181855) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO181855.js) |
293293
| 23.11.22. | `Level 0` | [더 크게 합치기](https://school.programmers.co.kr/learn/courses/30/lessons/181939) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO181939.js) |
294294
| 23.11.23. | `Level 0` | [구슬을 나누는 경우의 수](https://school.programmers.co.kr/learn/courses/30/lessons/120840) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO120840.js) |
295+
| 23.11.24. | `Level 0` | [콜라츠 수열 만들기](https://school.programmers.co.kr/learn/courses/30/lessons/181919) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO181919.js) |

0 commit comments

Comments
(0)

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