- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFactorial.java
More file actions
Latest commit
24 lines (21 loc) · 555 Bytes
/
Copy pathFactorial.java
File metadata and controls
24 lines (21 loc) · 555 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
importjava.io.*;
classFactorial {
publicstaticvoidmain(String[] args) throwsIOException {
BufferedReaderbr = newBufferedReader(newInputStreamReader(System.in));
intnumLines = Integer.parseInt(br.readLine());
for (inti = 0; i < numLines; i++) {
intnum = Integer.parseInt(br.readLine());
System.out.println(numZeroes(num));
}
System.exit(0);
}
publicstaticintnumZeroes(intnum) {
intresult = 0;
intdivisor = 5;
while (num / divisor >= 1) {
result += num / divisor;
divisor *= 5;
}
returnresult;
}
}