We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d96bcd7 commit ccea6fbCopy full SHA for ccea6fb
프로그래머스/2/12924. 숫자의 표현/README.md
@@ -4,7 +4,7 @@
4
5
### 성능 요약
6
7
-메모리: 10.1 MB, 시간: 2.35 ms
+메모리: 54 MB, 시간: 1.91 ms
8
9
### 구분
10
@@ -16,7 +16,7 @@
16
17
### 제출 일자
18
19
-2024년 2월 1일 21:35:41
+2025년 05월 31일 22:07:20
20
21
### 문제 설명
22
프로그래머스/2/12924. 숫자의 표현/숫자의 표현.java
@@ -0,0 +1,25 @@
1
+class Solution {
2
+ public int solution(int n) {
3
+ int answer = 0;
+
+ for (int i = 1; i <= n; i++) {
+ int sum = 0;
+ // 현재 i부터 n까지 자연수를 더해가면서 합을 계산
+ for (int j = i; j <= n; j++) {
+ sum += j;
11
12
13
+ if (sum == n) {
14
+ answer++;
15
+ break;
+ }
+ // 합이 주어진 n보다 크면 내부 반복문 종료
+ if (sum > n) break;
23
+ return answer;
24
25
+}
0 commit comments