Count Trailing Zeros From Factorial Of A Number Using Java

 package demo;


public class TrailingZeros {


private static int findTrailingZeros(int n) {

int count = 0;

for (int i = 5; n / i >= 1; i = i * 5) {

count = count + n / i;

}

return count;

}


public static void main(String[] args) {

System.out.println(findTrailingZeros(100000000));


}

}


Comments

Popular posts from this blog

3 Lines of Code And You Can Download Your Favourite Youtube Video.

Leetcode Problem(Easy) Roman to Integer

Leetcode : (Find Minimum in Rotated Sorted Array)