Euler 34

import math


def igual_fact(num):
  
  suma = 0
  
  for i in str(num):
    
    suma += math.factorial(int(i))
    
  if suma == num:
    
    return True
    
  else:
    
    return False
    
suma = 0    
for i in range(1,3*10**6):

  if igual_fact(i):
    suma += i
    
print(suma - 3)