Divide the sum by ten ones

Let X = n = 0 2015 n ! X = \sum_{n=0}^{2015} n! . Again suppose Y = X m o d 1111111111 Y = X \bmod{ 1111111111} . Find The sum of digits of Y Y .


The answer is 42.

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.

2 solutions

Arulx Z
Jun 24, 2015
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
>>> def sumd(n):
        r = 0
        while n:
            r, n = r + n % 10, n / 10
        return r
>>> import math
>>> summ = 0
>>> for x in xrange(0, 2016):
        summ += math.factorial(x)
>>> print sumd(summ % 1111111111)
42

Brock Brown
Jul 20, 2015

Python 2.7:

1
2
3
4
5
from math import factorial as fac
x = sum((fac(n) for n in range(2016)))
y = x % 1111111111
answer = sum((int(d) for d in str(y)))
print "Answer:", answer

If you will solve in c++, please post it.

Shohag Hossen - 5 years, 9 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...