需求:求出1000的阶乘所有零和尾部零的个数,不用递归做
BigInteger s = new BigInteger("1");
for (int i = 1; i <= 1000; i++) {
BigInteger s1 = new BigInteger(i + "");
s = s .multiply(s1);
}
String str = s.toString();
StringBuffer s1 = new StringBuffer(str);
str = s1.reverse().toString();
int count = 0;
for (int i = 0; i < str.length(); i++) {
if ('0' != str.charAt(i)) {
break;
}else{
count++;
}
}
System.out.println(count);
}