import unittest
def digit_sum(power):
if type(power)!=int or power<2:
return None
list1=[]
for i in range(2,1000000):
num=0
for j in str(i):
num+=(int(j))**power
if num==i:
list1.append(i)
return sum(list1)
print(digit_sum(5))
class TestCases(unittest.TestCase):
def test_digit_sum(self):
self.assertEqual(digit_sum(-5),None)
self.assertEqual(digit_sum(2),0)
self.assertEqual(digit_sum(4),19316)
self.assertEqual(digit_sum("5"),None)
self.assertEqual(digit_sum(4.5),None)
if __name__ == "__main__":
unittest.main()