Project Euler #34: Digit factorials

  • + 0 comments
    def fact(n):
        if n==0 or n==1:
            return 1
        else:
            return n*fact(n-1)
    sum=0
    for i in range(10, int(input())+1):
        sum1=0
        for j in str(i):
            sum1+=fact(int(j))
        if(sum1%i==0):
            sum+=i
    print(sum)