Exemplo n.º 1
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Problem 16
# http://projecteuler.net/index.php?section=problems&id=16
#
# 2 ** 15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
# What is the sum of the digits of the number 2 ** 1000?
#
# Solved by Evaldo Junior <*****@*****.**>
# November, 28th - 2010
#
import sys
sys.path.append("libs")
from mynumbers import sumDigits

giant_number = 2

for i in range(1, 1000):
    giant_number *= 2

print("The of digits is %i" % (sumDigits(giant_number)))
Exemplo n.º 2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Problem 20
# http://projecteuler.net/index.php?section=problems&id=20
#
# n! means n  (n  1)  ...  3  2  1
# Find the sum of the digits in the number 100!
#
# Solved by Evaldo Junior <*****@*****.**>
# November, 28th - 2010
#
import sys
sys.path.append("libs")
from myfactorial import factorial
from mynumbers import sumDigits

number = factorial(100)

print("The sum of digits of 100! is %i" % (sumDigits(number)))