I got stuck with a question in which I have first to find the factorial of a number and then return the number of digits obtained in the factorial. I wrote the program and it's working fine. But the time is 5.0015 sec and I have to do in 1 sec. How to reduce this?
Below is my program:
def factorial(n):
fact = 1
for y in xrange(1,n+1):
fact = fact * y
return fact
t = int(raw_input())
raw_input()
for x in xrange(t):
n = int(raw_input())
print len(str(factorial(n)))