Exemplo n.º 1
0
def main():
    sumNum = 0
    numOfDigits = 7
    upperBound = fact(9) * numOfDigits
    print 'upperBound Guess  9! x %d = %d ' %(numOfDigits,upperBound)
    for num in xrange(3,upperBound):
        sumDigitsFact = 0;
        for d in str(num):
            sumDigitsFact +=fact(int(d))
        if(sumDigitsFact == num):
            sumNum += num
            print num
    print sumNum
Exemplo n.º 2
0
def main():
    sumNum = 0
    numOfDigits = 7
    upperBound = fact(9) * numOfDigits
    print 'upperBound Guess  9! x %d = %d ' % (numOfDigits, upperBound)
    for num in xrange(3, upperBound):
        sumDigitsFact = 0
        for d in str(num):
            sumDigitsFact += fact(int(d))
        if (sumDigitsFact == num):
            sumNum += num
            print num
    print sumNum
Exemplo n.º 3
0
"""
n! means n  (n  1)  ...  3  2  1

For example, 10! = 10  9  ...  3  2  1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.

Find the sum of the digits in the number 100!
"""

from utils.fact import fact


def sumDigits(s):
    ssum = 0
    for i in s:
        ssum += int(i)
    return ssum


x = str(fact(100))
print sumDigits(x)
Exemplo n.º 4
0
"""
n! means n  (n  1)  ...  3  2  1

For example, 10! = 10  9  ...  3  2  1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.

Find the sum of the digits in the number 100!
"""

from utils.fact import fact

def sumDigits(s):
    ssum = 0
    for i in s:
        ssum +=  int(i)
    return ssum

x = str(fact(100))
print sumDigits(x)