// you’re reading...

Project Euler Solutions

Project Euler Problem 20 Solution

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Problem Description

n! means n × (n − 1) × … × 3 × 2 × 1

Find the sum of the digits in the number 100!

Analysis

Same solution as problem 16.

Solution

Runs < 1 second in Python.

def fact(n): return reduce(lambda x,y:x*y,range(1,n+1),1)
 
print "Answer to PE20 = ", sum(int(i) for i in str(fact(100)))

Comments

Discussion

No comments for “Project Euler Problem 20 Solution”

Post a comment