You are viewing a single comment's thread. Return to all comments →
def memo(a): if(a==0): return(1) if(a==1): return(1) if(a==2): return(2) if(a==3): return(6) if(a==4): return(24) if(a==5): return(120) if(a==6): return(720) if(a==7): return(5040) if(a==8): return(40320) if(a==9): return(362880) def fun(num): tot=0
for i in range(len(num)): tot+=memo(int(num[i])) if(tot%int(num)==0): return(True) else: return(False)
num=int(input()) for i in range(num,1,-1): if(fun(str(i))): print(i) break
why is my code wrong
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #34: Digit factorials
You are viewing a single comment's thread. Return to all comments →
def memo(a): if(a==0): return(1) if(a==1): return(1) if(a==2): return(2) if(a==3): return(6) if(a==4): return(24) if(a==5): return(120) if(a==6): return(720) if(a==7): return(5040) if(a==8): return(40320) if(a==9): return(362880) def fun(num): tot=0
num=int(input()) for i in range(num,1,-1): if(fun(str(i))): print(i) break