way to calculate 2**1000 without expanding it?

Arnaud Delobelle arnodel at gmail.com
Sun Sep 18 10:10:10 EDT 2011


On Sep 18, 2011 1:20 PM, "Mark Dickinson" <dickinsm at gmail.com> wrote:
>
> On Sep 16, 9:17 pm, Arnaud Delobelle <arno... at gmail.com> wrote:
> > Ah go on, let's make a codegolf contest out of it.
> > My entry:
> >
> > >>> sum(map(int,str(2**1000)))
>
> You could save another character by replacing "2**1000" with "2<<999"
>

Excellent!

-- 
Arnaud
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110918/f52ec8e2/attachment-0001.html>


More information about the Python-list mailing list