how many "0"

Dec 21, 2016 at 9:05pm
how can i find how many digits "0" end record number N!(factorial N) in K-ary number system.
for example if N=10000 and K=10 answer is 2499, if N=123456789 and K=4800 answer is 15432096.
Last edited on Dec 21, 2016 at 9:06pm
Dec 22, 2016 at 7:15pm
Calculate the number, then go trough it and count the 0s:
1
2
3
4
5
6
7
8
9
10
int n;
int zeros = 0;
///calculate n
do
{
    int digit = n%10; //returns the last digit. For example, 15%10 = 5
    if(digit == 0) {zeros++;} //if the last digit is 0, add one to the zero count
    n=n/10; //divide n by 10 to get rid of the last digit; 123/10=12

}while(n>0); //keep doing it untill the number is 0 
Dec 22, 2016 at 10:13pm
what about factorial n?
Dec 22, 2016 at 10:13pm
and system?
Dec 23, 2016 at 11:46am
how many digits "0" end

"end"?

Does that mean "trailing zeroes" or "zeros at the end of" rather than "all digits in the factorial that happen to be 0?

Search web with "zeros in factorial". The solutions that you should find are for base 10. Adjust to base K.
Dec 23, 2016 at 5:13pm
Topic archived. No new replies allowed.