Skip to content

Commit 554dc34

Browse files
committed
[level 0] Title: 짝수의 합, Time: 0.03 ms, Memory: 81.8 MB -BaekjoonHub
1 parent d8a25e7 commit 554dc34

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# [level 0] 짝수의 합 - 120831
2+
3+
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/120831)
4+
5+
### 성능 요약
6+
7+
메모리: 81.8 MB, 시간: 0.03 ms
8+
9+
### 구분
10+
11+
코딩테스트 연습 > 코딩테스트 입문
12+
13+
### 채점결과
14+
15+
정확성: 100.0<br/>합계: 100.0 / 100.0
16+
17+
### 제출 일자
18+
19+
2024년 12월 26일 21:58:53
20+
21+
### 문제 설명
22+
23+
<p>정수 <code>n</code>이 주어질 때, <code>n</code>이하의 짝수를 모두 더한 값을 return 하도록 solution 함수를 작성해주세요.</p>
24+
25+
<hr>
26+
27+
<h5>제한사항</h5>
28+
29+
<p>0 &lt; <code>n</code> ≤ 1000</p>
30+
31+
<hr>
32+
33+
<h5>입출력 예</h5>
34+
<table class="table">
35+
<thead><tr>
36+
<th>n</th>
37+
<th>result</th>
38+
</tr>
39+
</thead>
40+
<tbody><tr>
41+
<td>10</td>
42+
<td>30</td>
43+
</tr>
44+
<tr>
45+
<td>4</td>
46+
<td>6</td>
47+
</tr>
48+
</tbody>
49+
</table>
50+
<hr>
51+
52+
<h5>입출력 예 설명</h5>
53+
54+
<p>입출력 예 #1</p>
55+
56+
<ul>
57+
<li><code>n</code>이 10이므로 2 + 4 + 6 + 8 + 10 = 30을 return 합니다.</li>
58+
</ul>
59+
60+
<p>입출력 예 #2</p>
61+
62+
<ul>
63+
<li><code>n</code>이 4이므로 2 + 4 = 6을 return 합니다.</li>
64+
</ul>
65+
66+
67+
> 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/challenges
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public int solution(int n) {
3+
int answer = 0;
4+
5+
for(int i=0; i<=n; i+=2){
6+
answer+=i;
7+
}
8+
9+
return answer;
10+
}
11+
}

0 commit comments

Comments
 (0)