Number trailing zeros in factorial in java
<pre><code>import java.util.Scanner;
import java.io.*;
class factorial {

    void fact(int a) {
        int i;
        int ar[] = new int[10000];
        int fact = 1, count = 0;
        for (i = 1; i &lt;= a; i++) {

            fact = fact * i;
        }
        String str1 = Integer.toString(fact);
        int len = str1.length();
        i = 0;
        do {
            ar[i] = fact % 10;
            fact /= 10;
            i++;
        } while (fact != 0);
        for (i = 0; i &lt; len; i++) {
            if (ar[i] == 0) {
                count = count + 1;
            }
        }
        System.out.println(count);
    }
    public static void main(String...ab) {
        int a;
        Scanner input = new Scanner(System.in);
        a = input.nextInt();
        factorial ob = new factorial();
        ob.fact(a);
    }
}
</code></pre>

<p>This code is work up to <code>a = 10</code> but after enter number larger then <code>a = 16</code> it gives wrong answer.
Please help.
    As I am not able to post this question if I dont add more info for this question but I assume that the info I provide above is enough to under stand what I want.</p>