title: Counting trailing zeros of numbers resulted from factorial
body: <p>I'm trying to count trailing zeros of numbers that are resulted from factorials (meaning that the numbers get quite large). Following code takes a number, compute the factorial of the number, and count the trailing zeros. However, when the number is about as large as <code>25!</code>, numZeros don't work.</p>
  <pre><code>public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      double fact;
      int answer;
          
      try {
          int number = Integer.parseInt(br.readLine());
          fact = factorial(number);
          answer = numZeros(fact);
      }
      catch (NumberFormatException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  
  public static double factorial (int num) {
      double total = 1;
      for (int i = 1; i &lt;= num; i++) {
          total *= i;
      }
      return total;
  }   
  
  public static int numZeros (double num) {
      int count = 0;
      int last = 0;   
  
      while (last == 0) {
          last = (int) (num % 10);
          num = num / 10;
          count++;
      }
      
      return count-1;
  }
  </code></pre>
  <p>I am not worrying about the efficiency of this code, and I know that there are multiple ways to make the efficiency of this code BETTER. What I'm trying to figure out is why the counting trailing zeros of numbers that are greater than <code>25!</code> is not working.</p>
  <p>Any ideas?</p>