我需要找到给定数字的尾随零。在因子中查找尾随零
对于较小的输入,它可以很好地工作,但对于较长的输入,它不能很好地工作。
long input=s.nextInt();
long mul=1;
int count=0;
while(input!=1 && input<1000000000)
{
log.debug("mul="+mul+"Input="+input+"count="+count);
mul =mul*input;
input--;
while(mul%10==0)
{
count++;
mul=mul/10;
}
mul=mul%100;
//if()
}
System.out.println(count);
log.debug(count);
count=0;
对于输入
6//Working Correct
3//Working Correct
60//Working Correct
100//Working Correct
1024//Working Correct
23456//Working Wrong
8735373//Working Wrong
预期输出:
0
14
24
253
5861//My output is 5858
2183837//My output is 2182992
你试过寻找这个问题吗?已经讨论了很多次 – radoh
是否被定义为长? –
@GilbertLeBlanc是的,其长 – Renigunda