-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[level 1] Title: 자릿수 더하기, Time: 0.00 ms, Memory: 10.1 MB -BaekjoonHub
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# [level 1] 자릿수 더하기 - 12931 | ||
|
||
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/12931?language=python3) | ||
|
||
### 성능 요약 | ||
|
||
메모리: 10.1 MB, 시간: 0.00 ms | ||
|
||
### 구분 | ||
|
||
코딩테스트 연습 > 연습문제 | ||
|
||
### 채점결과 | ||
|
||
정확성: 100.0<br/>합계: 100.0 / 100.0 | ||
|
||
### 제출 일자 | ||
|
||
2024년 05월 09일 13:20:19 | ||
|
||
### 문제 설명 | ||
|
||
<p>자연수 N이 주어지면, N의 각 자릿수의 합을 구해서 return 하는 solution 함수를 만들어 주세요.<br> | ||
예를들어 N = 123이면 1 + 2 + 3 = 6을 return 하면 됩니다.</p> | ||
|
||
<h5>제한사항</h5> | ||
|
||
<ul> | ||
<li>N의 범위 : 100,000,000 이하의 자연수</li> | ||
</ul> | ||
|
||
<hr> | ||
|
||
<h5>입출력 예</h5> | ||
<table class="table"> | ||
<thead><tr> | ||
<th>N</th> | ||
<th>answer</th> | ||
</tr> | ||
</thead> | ||
<tbody><tr> | ||
<td>123</td> | ||
<td>6</td> | ||
</tr> | ||
<tr> | ||
<td>987</td> | ||
<td>24</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<h5>입출력 예 설명</h5> | ||
|
||
<p>입출력 예 #1<br> | ||
문제의 예시와 같습니다.</p> | ||
|
||
<p>입출력 예 #2<br> | ||
9 + 8 + 7 = 24이므로 24를 return 하면 됩니다.</p> | ||
|
||
|
||
> 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/challenges |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
def solution(n): | ||
sum_ = 0 | ||
while n > 0 : | ||
sum_ += n % 10 | ||
n = n // 10 | ||
|
||
#print(sum) | ||
|
||
return sum_ |