MCPcopy Create free account
hub / github.com/careercup/ctci / countFactZeros

Method countFactZeros

java/Chapter 17/Question17_3/QuestionB.java:4–14  ·  view source on GitHub ↗
(int num)

Source from the content-addressed store, hash-verified

2
3public class QuestionB {
4 public static int countFactZeros(int num) {
5 int count = 0;
6 if (num < 0) {
7 System.out.println("Factorial is not defined for negative numbers");
8 return 0;
9 }
10 for (int i = 5; num / i > 0; i *= 5) {
11 count += num / i;
12 }
13 return count;
14 }
15
16 public static int factorial(int num) {
17 if (num == 1) {

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected