title: Time limit exceeded on spoj.FCTRL
body: <p>I have to generate the number of trailing zeros at the end of factorial of a integer.first input is the no of test cases'T'. Next T lines contain the input integers. Output should have the number of zeros at the end of factorial of input integers. Here is my code but it gives time limit exceeded.Please help me optimize .</p>
  
  <pre><code>T=int(raw_input())
  a=[]
  for i in range(0,T):
  
      a.append(int(raw_input()))
  def factorial (n):
      fact=1
      while(n&gt;0):
          fact=fact*n
          n=n-1
      return fact
  
  b=[]
  for i in range(0,T):
      b.append(factorial(a[i]))
  
  
  c=[]
  
  for i in range(0,T):
      ans=0
      while(b[i]%10 == 0):
          ans=ans+1
          b[i]=b[i]/10
      c.append(ans)
  for i in range(T):
      print c[i],
  </code></pre>