Exemplo n.º 1
0
 def test_sum_digits(self):
     self.assertEqual(mathhelper.sum_digits(-1), 1)
     self.assertEqual(mathhelper.sum_digits(0), 0)
     self.assertEqual(mathhelper.sum_digits(1), 1)
     self.assertEqual(mathhelper.sum_digits(2), 2)
     self.assertEqual(mathhelper.sum_digits(21), 3)
     self.assertEqual(mathhelper.sum_digits(867), 21)
     self.assertEqual(mathhelper.sum_digits(99000009), 27)
Exemplo n.º 2
0
def problem20():
    """ Factorial digit sum
    Find the sum of the digits in the number 100!

    """
    return mathhelper.sum_digits(math.factorial(100))
Exemplo n.º 3
0
def problem16():
    """ Power digit sum
    What is the sum of the digits of the number 2^1000?

    """
    return mathhelper.sum_digits(2 ** 1000)