hi everyone, i have a problem with the trailing zeros quest. i am allways geting Wrong Answer and dont know what i am doing wrong.
I made several tests that give-me the correct answers.
examples:
5-1
10-2
25-6
32-7
64-14
125-31
8735373-2183837
1000000000-249999998
my code is:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws java.lang.Exception {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader stdin = new BufferedReader(isr);
String input = stdin.readLine();
int n = Integer.parseInt(input);
int zeros = 0;
for (int i = 1; Math.pow(5, i) < n; i++) {
zeros = (int) (zeros + n / (Math.pow(5, i)));
if (n == Math.pow(5, i + 1)) {
zeros = zeros + 1;
}
}
if (n == 5) {
zeros = 1;
}
System.out.println(zeros);
}
}
Can you help me?
best regards