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 61ab0a5

Browse files
Add 콜라츠-추측.js / comment 주석오타 수정
1 parent 11af24a commit 61ab0a5

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

‎level-1/콜라츠-추측.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function solution(num) {
4646
return num == 1 ? answer : -1
4747
}
4848

49-
//정답 3 - prove-ability
49+
//정답 4 - prove-ability
5050
function solution(num) {
5151
let count = 0;
5252

@@ -62,4 +62,14 @@ function solution(num) {
6262
}
6363

6464
return count;
65-
}
65+
}
66+
67+
//정답 5 - yongchanson
68+
function solution(num) {
69+
let count = 0;
70+
while (num !== 1) {
71+
if (count++ === 500) return -1;
72+
num = num % 2 ? num * 3 + 1 : num / 2;
73+
}
74+
return count;
75+
}

0 commit comments

Comments
(0)

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