输入一个数字,这个数的阶乘最后会有几个0
思路,每一个5就会产生一个0,25=5*5,相当于两个5,也就会产生2个0,最后累加5的个数,不用所谓的阶乘
#include<stdio.h> #include <stdlib.h> void main() { int c; int t=0; printf("please enter anumber:"); scanf("%d",&c); for(int i=0;i<=c;i+=5) { int w=i; while(w/5&&!(w%5)) { t++; w=w/5; } } printf("num have 0:%d",t); scanf("%d",c); }