This question shows research effort; it is useful and clear
7
This question does not show any research effort; it is unclear or not useful
Bookmark this question.
Show activity on this post.
我想知道它:
> %timeit sum([int(digit) for digit in str(n)])
100000 loops, best of 3: 1.52 us per loop
> %timeit sum(int(digit) for digit in str(n))
100000 loops, best of 3: 2.04 us per loop