We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defget_factorial2(n):old=[1]current=[]foriinxrange(2,n+1):carry=0fordigitinold:prod=int(digit)*i+carryrem=prod%10current.append(rem)carry=prod/10ifcarry!=0:forjinstr(carry)[::-1]:current.append(j)# add j as a strold=currentcurrent=[]return"".join(map(str,old[::-1]))# convert everything to str before concatenation and returning the resultsn=int(raw_input().strip())printget_factorial2(n)
Here my python solution using super carry method. Exactly same as @etayluz's
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Extra Long Factorials
You are viewing a single comment's thread. Return to all comments →
Here my python solution using super carry method. Exactly same as @etayluz's