What is the sum of the digits of the number 2^1000?

前端 未结 10 1889
别跟我提以往
别跟我提以往 2021-01-02 03:13

This is a problem from Project Euler, and this question includes some source code, so consider this your spoiler alert, in case you are interested in solving it yourself. It

10条回答
  •  攒了一身酷
    2021-01-02 03:50

    Python makes it very simple to compute this with an oneliner:

    print sum(int(digit) for digit in str(2**1000))
    

    or alternatively with map:

    print sum(map(int,str(2**1000)))
    

提交回复
热议问题