日期:2014-05-20 浏览次数:20831 次
String b=""+a;
for(int i=0;i<b.length();i++)
{
if(i<b.length()-1)
{
if(b.charAt(i)=='0'&&b.charAt(i+1)=='0')
{
total++;
}
}
}
System.out.print(total);
import java.util.Scanner;
import java.math.BigInteger;
public class Cal0atEndsByBigInteger1
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
Scanner rd=new Scanner(System.in);
int total=0;
System.out.println("请输入起始数:");
int n=rd.nextInt();
int m;
do
{
System.out.println("请输入截止数:");
m=rd.nextInt();
}while(m<n);
String product=multiplyNM(n,m);
int length=product.length();
for(int i=0;i<product.length();i++)
{
char c=product.charAt(length-i-1);
if(c!='0')
{
break;
}
else
{
total++;
}
}
System.out.print(n+" 到"+m+" 连乘 = "+product+" 后面有\"0\" "+total+" 个");
}
//用大数字计算阶乘,并返回字符串
//
public static String multiplyNM(int n,int m) //返回字符串
{
BigInteger sum=new BigInteger("1");
for(int i=n;i<=m;i++)
{
sum=sum.multiply(new BigInteger(""+i));
}
return sum.toString();
}
}
public static int cal1(long y)
{
String s=""+y;
int length=s.length();
int total=0;
for(int i=0;i<length;i++)
{
char c=s.charAt(length-i-1);
if(c!='0')
{
break;
}
else
{
total++;
}
}
return total;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner rd=new Scanner(System.in);
int total=0;
int n=rd.nextInt();
int a=Factorial(n);
String b=""+a;
int length=b.length();
for(int i=0;i<b.length();i++)
{
char c=b.charAt(length-i-1);
if(c!='0')
{
break;
}
else
total++;
}
System.out.print(total);
}
public static int Factorial(int n)
{
int sum=1;
for(int i=1;i<=n;i++)
{
sum*=i;
}
return sum;
}