일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- #2차원배열
- border-box
- #CallByAddress
- html multimedia
- #3차원배열
- #bubbleSort
- #성적관리프로그램
- html id
- git flow
- html youtube
- #1차원배열
- #C++ has~a
- 하이퍼레저패브릭
- html5 new tag
- #JAVASCRIPT
- 토큰경제
- html code
- #binary
- #C++ 연산자함수오버로딩
- relative path
- #자바상속#자바이즈어#is~a
- html video
- docker example
- hyperledger transaction
- mac terminal command
- html object
- #다차원포인터
- #android activity
- html plug-in
- html charset
Archives
- Today
- Total
A sentimental robot
콜라체의 수 / 우박수 본문
// 어떤 수든 1로 수렴
int n = 2018;
while (true) {
System.out.println(n);
if (n % 2 == 0)
n = n / 2;
else
n = n * 3 + 1;
if (n == 1)
break;
}
System.out.println(n);
// 삼항 연산자 사용
int n = 2018;
while (true) {
System.out.println(n);
n = (n % 2 == 0) ? n / 2 : n * 3 + 1;
if (n == 1)
break;
}
System.out.println(n);
'Data Structure' 카테고리의 다른 글
quirt some (0) | 2018.02.13 |
---|---|
Bubble sort (0) | 2018.01.03 |
Double LinkedList (0) | 2018.01.03 |
Single LinkedList Exercise3 (0) | 2018.01.03 |
Map에 대하여.. (0) | 2018.01.03 |