n! is 1 x 2 x 3 x 4 x 5 x .. x (n -1) x n.

Trailing zeros is the result of multilpy even number and every fifth number.

We have enough even numbers. So we should count the number of “every fifth”.

Additional zeros is given by numbers which are the multiply of more than one 5s (25, 125, 625 …)

			
public int count(int n) {
    count = 0;
    // the first iteration
    count = n / 5;
    // the second iteration
    count = count + n / 25
	
    .... 
		
    // We end iterations if  (n / (5 * .. *5 * 5)) < 1
    return count;
}

In general we have:

			
public int calculateNumberOfZeros(int n) {
    int count = 0;
    for (int i = 5; i <= n; i *= 5) {
        count = count + n / i;
    }
    return count;
}

We can include negative values intercepting but our method is able to handle this situation because number of trailing zeros of non existing (-n) factorial is 0