package LeetCode;

public class FactorialTrailingZeroes {
	public int trailingZeroes(int n) {
		if (n == 0) {
			return 1;
		}

		int res = 0;
		for (long i = 5; i <= n; i = i + 5) {
			res = count(i, res);
		}
		return res;
	}

	public int count(long i, int count) {
		if (i % 5 == 0) {
			count++;
			return count(i / 5, count);
		}
		return count;
	}

	public int count2(long i, int count) {
		int c = 0;
		if (i >= 1220703125) {
			c = 13;
		} else if (i >= 244140625) {
			c = 12;
		} else if (i >= 48828125) {
			c = 11;
		} else if (i >= 9765625) {
			c = 10;
		} else if (i >= 1953125) {
			c = 9;
		} else if (i >= 390625) {
			c = 8;
		} else if (i >= 78125) {
			c = 7;
		} else if (i >= 15625) {
			c = 6;
		} else if (i >= 3125) {
			c = 5;
		} else if (i >= 625) {
			c = 4;
		} else if (i >= 125) {
			c = 3;
		} else if (i >= 25) {
			c = 2;
		} else if (i >= 5) {
			c = 1;
		}
		return count + c;
	}
}

@@ -94,800 +94,60 @@
 %0A%09%09i
-f (n == 0) %7B%0A%09%09%09return 1;%0A%09%09%7D%0A%0A%09%09int res = 0;%0A%09%09for (long i = 5; i %3C= n; i = i + 5) %7B%0A%09%09%09res = count(i, res);%0A%09%09%7D%0A%09%09return res;%0A%09%7D%0A%0A%09public int count(long i, int count) %7B%0A%09%09if (i %25 5 == 0) %7B%0A%09%09%09count++;%0A%09%09%09return count(i / 5, count);%0A%09%09%7D%0A%09%09return count;%0A%09%7D%0A%0A%09public int count2(long i, int count) %7B%0A%09%09int c = 0;%0A%09%09if (i %3E= 1220703125) %7B%0A%09%09%09c = 13;%0A%09%09%7D else if (i %3E= 244140625) %7B%0A%09%09%09c = 12;%0A%09%09%7D else if (i %3E= 48828125) %7B%0A%09%09%09c = 11;%0A%09%09%7D else if (i %3E= 9765625) %7B%0A%09%09%09c = 10;%0A%09%09%7D else if (i %3E= 1953125) %7B%0A%09%09%09c = 9;%0A%09%09%7D else if (i %3E= 390625) %7B%0A%09%09%09c = 8;%0A%09%09%7D else if (i %3E= 78125) %7B%0A%09%09%09c = 7;%0A%09%09%7D else if (i %3E= 15625) %7B%0A%09%09%09c = 6;%0A%09%09%7D else if (i %3E= 3125) %7B%0A%09%09%09c = 5;%0A%09%09%7D else if (i %3E= 625) %7B%0A%09%09%09c = 4;%0A%09%09%7D else if (i %3E= 125) %7B%0A%09%09%09c = 3;%0A%09%09%7D else if (i %3E= 25) %7B%0A%09%09%09c = 2;%0A%09%09%7D else if (i %3E= 5) %7B%0A%09%09%09c = 1
+nt res = 0;%0A%09%09while (n %3E 0) %7B%0A%09%09%09n /= 5;%0A%09%09%09res += n
 ;%0A%09%09
@@ -161,17 +161,11 @@
 urn 
-count + c
+res
 ;%0A%09%7D

modify factorial trailing zeroes