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)
def problem20(): """ Factorial digit sum Find the sum of the digits in the number 100! """ return mathhelper.sum_digits(math.factorial(100))
def problem16(): """ Power digit sum What is the sum of the digits of the number 2^1000? """ return mathhelper.sum_digits(2 ** 1000)