n! means n * (n-1) * … * 3 * 2 * 1
Find the sum of the digits in the number 100!
#!/usr/bin/env python
t = 1
x = 0
for i in range(1,101):
t = t * i
for i in str(t):
x = x + int(i)
print x
/home/umgeher/war/hg/euler/python> time python 20.py 648 Time spent in user mode (CPU seconds) : 0.016s Time spent in kernel mode (CPU seconds) : 0.008s Total time : 0:00.02s CPU utilisation (percentage) : 50.0% Times the process was swapped : 0 Times of major page faults : 0 Times of minor page faults : 649 /home/umgeher/war/hg/euler/python>

The Day Shift by pg.lost





0 Comments.