반응형
215 = 32768 의 각 자리수를 더하면 3 + 2 + 7 + 6 + 8 = 26 입니다.
21000의 각 자리수를 모두 더하면 얼마입니까?
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
#python3 | |
import math | |
def cal_digit(x, y) : | |
num = pow(x, y) | |
digit_sum = 0 | |
for i in list(str(num)) : | |
digit_sum += int(i) | |
return digit_sum | |
print(cal_digit(2, 1000)) |
반응형
'개발 > 알고리즘 문제' 카테고리의 다른 글
[Project Euler 20] 100! 의 자리수를 모두 더하면? (0) | 2016.03.01 |
---|---|
[Project Euler 18] 삼각형을 따라 내려가면서 합이 최대가 되는 경로 찾기 (0) | 2016.03.01 |
[Project Euler 15] 20×20 격자의 좌상단에서 우하단으로 가는 경로의 수 (0) | 2016.03.01 |
[Project Euler 14] 백만 이하로 시작하는 우박수 중 가장 긴 과정을 거치는 것은? (1) | 2016.03.01 |
[Project Euler 13] 50자리 숫자 100개를 더한 값의 첫 10자리 구하기 (0) | 2016.03.01 |
댓글