Factorial digit sum

Find the sum of the digits in the number 2015 ! 2015! .


The answer is 23517.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

4 solutions

Kartik Sharma
Oct 8, 2015

Well, the following program is really too straight-forward but it worked in 2 s on my Python IDLE.

1
2
3
4
5
6
>>> import math
>>> s = 0
>>> for i in str(math.factorial(2015)):
    s +=int(i)
>>> print s
23517

1 line of code def sumoffactorialdigits(n): print (sum(map(int,str( functools.reduce(operator.mul, range(1,n+1))))))

Hasmik Garyaka - 3 years, 9 months ago
Arulx Z
Nov 3, 2015

It's easy to directly compute the answer

1
2
3
>>> import math
>>> sum(int(x) for x in str(math.factorial(2015)))
23517

Vijay Kumar
Jan 26, 2016

print reduce(lambda x,y : x+y , [0]+map(int,list(str(fact[2015]))))

Ramiel To-ong
Dec 16, 2015

nice problem

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...