找出n的阶乘末尾有几个零

原理:因为10由2*5组成,而构成2的因数比5多 所以最终转换成求5的个数

int getNumber(int n)
{
	int count = 0;
	while(n)
	{
		n = n/5;
		count = count +n;
	}
	return count;
}

 

posted @ 2013-09-03 23:26  l851654152  阅读(109)  评论(0编辑  收藏  举报