Computer Science, asked by DarshanMS2456, 11 months ago

A program to find the number of trailing zeroes for the factorial of a given number.

Answers

Answered by Zisha7
0

Answer:

C/C++ Program to Count trailing zeroes in factorial of a number. Given an integer n, write a function that returns count of trailing zeroes in n!. Trailing 0s in n! = Count of 5s in prime factors of n! = floor(n/5) + floor(n/25) + floor(n/125) + ....

Answered by meghamsh763
0

Explanation:

{

long int n=0,facto=1,ln=0;

int zcount=0,i=1;

printf("Enter a number:");

scanf("%ld",&n);

if(n==0)

{

facto=1;

}

else

{

for(i=1;i<=n;i++)

{

facto=facto*i;

}

}

printf("%ld",facto);

while(facto>0)

{

ln=facto%10;

facto/10;

if(ln=!0)

{

break;

}

else

{

zcount+=1;

}

}

printf("Tere are Total %d Trailing zeros in given factorial",zcount);

}

Similar questions