way to calculate 2**1000 without expanding it?
stefan-usenet at bytereef.org
Fri Sep 16 23:07:31 CEST 2011
Gary Herron <gherron at digipen.edu> wrote:
>>>> i am writing a program to sum up the digits of a number 2**1000?
>>>> Is there a way/formula to do it without expanding it?
> Here's another one-liner using a generator instead of map:
> sum(int(c) for c in str(2**1000))
The OP did not specify the base:
More information about the Python-list