Project Euler #34: Digit factorials

  • + 0 comments

    Here is my code : 100 points

    def factorial(x):
        if x==0:
            return 1
        return x*factorial(x-1)
    lookup=[0]*1000001
    sum_=0
    for i in range(10,100000+1):
        s=0
        t=i
        while t>0:
            r=t%10
            s+=factorial(r)
            t=t//10
        if s%i==0:
            sum_+=i
        lookup[i]=sum_
    n=int(input().strip())
    print(lookup[n])