Project Euler 20.

Ian Kelly ian.g.kelly at gmail.com
Sun Sep 24 19:23:10 EDT 2017


On Sun, Sep 24, 2017 at 4:35 PM, Paul Rubin <no.email at nospam.invalid> wrote:
>
> "Robert L." <No_spamming at noWhere_7073.org> writes:
> >> Find the sum of the digits in the number 100!
> > In Python?
>
> So you have come to plague us here too.
>
> >>> sum(ord(c)-ord('0') for c in str(reduce(lambda a,b: a*b, range(1,101),1)))
> 648

Or for any Python 2.6 or greater:

>>> sum(int(c) for c in str(math.factorial(100)))
648



More information about the Python-list mailing list