Skip to content

Commit 3fe44ed

Browse files
committed
[level 0] Title: 자릿수 더하기, Time: 0.01 ms, Memory: 75.8 MB -BaekjoonHub
1 parent 591a0d3 commit 3fe44ed

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

프로그래머스/0/120906. 자릿수 더하기/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# [level 0] 자릿수 더하기 - 120906
22

3-
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/120906?language=java)
3+
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/120906)
44

55
### 성능 요약
66

7-
메모리: 73.2 MB, 시간: 0.03 ms
7+
메모리: 75.8 MB, 시간: 0.01 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2026년 06월 21일 13:44:30
19+
2026년 06월 24일 09:29:47
2020

2121
### 문제 설명
2222

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
class Solution {
22
public int solution(int n) {
33
int ans = 0;
4-
while (true) {
5-
if (n / 10 < 1) {
6-
ans += n % 10;
7-
return ans;
8-
}
4+
while (n > 0) {
95
ans += n % 10;
10-
n = n / 10;
6+
n /= 10;
117
}
8+
return ans;
129
}
1310
}

0 commit comments

Comments
 (0)