Sudal's Garage

Project Euler 16 본문

Programming/Project Euler - python

Project Euler 16

_Sudal 2019. 3. 4. 05:00

Question: 


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?

문제:

215 = 32768 은 32768 이고, 자릿수를 모두 더하면 3 + 2 + 7 + 6 + 8 = 26 이다.

그렇다면 21000의 자릿수를 모두 더한 값은 무엇인가?


Solution:


print(eval('+'.join(list(str(2 ** 1000)))))


eval: 문자열을 바로 compute 해준다




'Programming > Project Euler - python' 카테고리의 다른 글

Project Euler 18  (0) 2019.03.06
Project Euler 17  (0) 2019.03.05
Project Euler 15  (0) 2019.03.03
Project Euler 14  (0) 2019.03.02
Project Euler 13  (0) 2019.02.28