[문제]
215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
What is the sum of the digits of the number 21000?
[풀이]
#number = 2**1000
#print(sum([int(i) for i in str(number)]))
print(sum([int(i) for i in str(2**1000)]))
'''
간단하게 풀었다
주석처리된 2줄을 밑의 한 줄로 바꿀 수 있다.
list comprehension을 사용할 수 있게되니까 코드가 참 간결해진다!
간결하기만 하다고 좋은건 아니겠지만...
'''
'파이썬' 카테고리의 다른 글
[Project Euler]18. 못풀었음 (0) | 2021.06.29 |
---|---|
[Project Euler]17. Number letter counts (0) | 2021.06.10 |
[Project Euler]15. Lattice paths (0) | 2021.06.09 |
[Project Euler]14. Longest Collatz sequence (0) | 2021.06.09 |
[Project Euler]13. Large sum (0) | 2021.06.07 |